FAILURE MAP
← Case archive

FA-59726 / Subscription proration billing / Open access

Current billing period containing a date: yearly interval scaling · case 01

Yearly plans roll over monthly and monthly plans yearly.

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

ROOT CAUSE

The months-per-interval factor is attached to the wrong interval.

THE FAILURE

The months-per-interval factor is attached to the wrong interval.

Unsuccessful approach: The attempt applies the count twice for yearly plans.

Case contract

Input {anchor, interval week|month|year, count, at >= anchor}. Period k starts at anchor + k*count intervals (weeks as 7 days; months/years by calendar month with the anchor day clamped to month length). Return [start ISO, end ISO] of the period with start <= at < end.

Why this case matters

Proration needs the exact period containing a change date; boundary dates belong to the new period.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
import calendar
N = 1
observations = []
def solve(x):
    a = datetime.date(*x['anchor'])
    t = datetime.date(*x['at'])
    def shift(k):
        if x['interval'] == 'week':
            return a + datetime.timedelta(days=7 * x['count'] * k)
        months = k * x['count'] * (12 if x['interval'] == 'month' else 1)
        tot = a.month - 1 + months
        y, m = a.year + tot // 12, tot % 12 + 1
        return datetime.date(y, m, min(a.day, calendar.monthrange(y, m)[1]))
    k = 0
    while shift(k + 1) <= t:
        k += 1
    return [shift(k).isoformat(), shift(k + 1).isoformat()]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'anchor': [2021, 11, 24], 'interval': 'year', 'count': 3, 'at': [2022, 4, 18]}, ['2021-11-24', '2024-11-24']), ('regression (boundary)', {'anchor': [2024, 1, 31], 'interval': 'month', 'count': 1, 'at': [2024, 2, 29]}, ['2024-02-29', '2024-03-31']), ('partial-repair probe', {'anchor': [2021, 2, 28], 'interval': 'year', 'count': 2, 'at': [2021, 8, 29]}, ['2021-02-28', '2023-02-28']), ('partial-repair probe', {'anchor': [2020, 11, 28], 'interval': 'year', 'count': 2, 'at': [2023, 9, 6]}, ['2022-11-28', '2024-11-28']), ('boundary control', {'anchor': [2024, 1, 10], 'interval': 'week', 'count': 2, 'at': [2024, 1, 24]}, ['2024-01-24', '2024-02-07']), ('normal control', {'anchor': [2020, 8, 2], 'interval': 'week', 'count': 3, 'at': [2020, 9, 4]}, ['2020-08-23', '2020-09-13']), ('normal control', {'anchor': [2020, 8, 7], 'interval': 'week', 'count': 2, 'at': [2023, 10, 30]}, ['2023-10-27', '2023-11-10']), ('normal control', {'anchor': [2021, 8, 15], 'interval': 'week', 'count': 1, 'at': [2024, 10, 23]}, ['2024-10-20', '2024-10-27']), ('normal control', {'anchor': [2020, 11, 21], 'interval': 'week', 'count': 2, 'at': [2022, 7, 12]}, ['2022-07-02', '2022-07-16'])], [('regression', {'anchor': [2021, 2, 28], 'interval': 'year', 'count': 2, 'at': [2021, 8, 29]}, ['2021-02-28', '2023-02-28']), ('regression', {'anchor': [2020, 10, 31], 'interval': 'year', 'count': 1, 'at': [2022, 2, 15]}, ['2021-10-31', '2022-10-31']), ('partial-repair probe', {'anchor': [2020, 11, 28], 'interval': 'year', 'count': 2, 'at': [2023, 9, 6]}, ['2022-11-28', '2024-11-28']), ('partial-repair probe', {'anchor': [2023, 3, 31], 'interval': 'year', 'count': 3, 'at': [2024, 8, 8]}, ['2023-03-31', '2026-03-31']), ('boundary control', {'anchor': [2024, 1, 10], 'interval': 'week', 'count': 2, 'at': [2024, 1, 24]}, ['2024-01-24', '2024-02-07']), ('normal control', {'anchor': [2021, 5, 20], 'interval': 'week', 'count': 1, 'at': [2022, 8, 31]}, ['2022-08-25', '2022-09-01']), ('normal control', {'anchor': [2022, 8, 21], 'interval': 'week', 'count': 1, 'at': [2025, 1, 26]}, ['2025-01-26', '2025-02-02']), ('normal control', {'anchor': [2020, 4, 24], 'interval': 'week', 'count': 1, 'at': [2021, 1, 14]}, ['2021-01-08', '2021-01-15']), ('normal control', {'anchor': [2020, 4, 15], 'interval': 'week', 'count': 1, 'at': [2022, 5, 12]}, ['2022-05-11', '2022-05-18'])], [('regression', {'anchor': [2020, 11, 28], 'interval': 'year', 'count': 2, 'at': [2023, 9, 6]}, ['2022-11-28', '2024-11-28']), ('regression', {'anchor': [2023, 10, 31], 'interval': 'month', 'count': 2, 'at': [2024, 2, 3]}, ['2023-12-31', '2024-02-29']), ('partial-repair probe', {'anchor': [2021, 9, 30], 'interval': 'year', 'count': 3, 'at': [2021, 12, 24]}, ['2021-09-30', '2024-09-30']), ('partial-repair probe', {'anchor': [2021, 6, 30], 'interval': 'year', 'count': 3, 'at': [2022, 7, 26]}, ['2021-06-30', '2024-06-30']), ('boundary control', {'anchor': [2024, 1, 10], 'interval': 'week', 'count': 2, 'at': [2024, 1, 24]}, ['2024-01-24', '2024-02-07']), ('normal control', {'anchor': [2021, 3, 2], 'interval': 'week', 'count': 1, 'at': [2023, 4, 10]}, ['2023-04-04', '2023-04-11']), ('normal control', {'anchor': [2023, 4, 28], 'interval': 'week', 'count': 1, 'at': [2024, 7, 31]}, ['2024-07-26', '2024-08-02']), ('normal control', {'anchor': [2020, 1, 18], 'interval': 'week', 'count': 3, 'at': [2021, 11, 30]}, ['2021-11-20', '2021-12-11']), ('normal control', {'anchor': [2020, 2, 8], 'interval': 'week', 'count': 1, 'at': [2021, 4, 15]}, ['2021-04-10', '2021-04-17'])], [('regression', {'anchor': [2023, 3, 31], 'interval': 'year', 'count': 3, 'at': [2024, 8, 8]}, ['2023-03-31', '2026-03-31']), ('regression', {'anchor': [2022, 10, 31], 'interval': 'month', 'count': 2, 'at': [2023, 6, 30]}, ['2023-06-30', '2023-08-31']), ('partial-repair probe', {'anchor': [2023, 12, 31], 'interval': 'year', 'count': 3, 'at': [2026, 4, 8]}, ['2023-12-31', '2026-12-31']), ('partial-repair probe', {'anchor': [2021, 9, 30], 'interval': 'year', 'count': 2, 'at': [2023, 8, 3]}, ['2021-09-30', '2023-09-30']), ('boundary control', {'anchor': [2024, 1, 10], 'interval': 'week', 'count': 2, 'at': [2024, 1, 24]}, ['2024-01-24', '2024-02-07']), ('normal control', {'anchor': [2020, 7, 6], 'interval': 'week', 'count': 2, 'at': [2023, 9, 7]}, ['2023-08-28', '2023-09-11']), ('normal control', {'anchor': [2022, 2, 27], 'interval': 'week', 'count': 1, 'at': [2023, 11, 19]}, ['2023-11-19', '2023-11-26']), ('normal control', {'anchor': [2021, 8, 13], 'interval': 'week', 'count': 1, 'at': [2023, 3, 26]}, ['2023-03-24', '2023-03-31']), ('normal control', {'anchor': [2021, 1, 2], 'interval': 'week', 'count': 2, 'at': [2021, 7, 13]}, ['2021-07-03', '2021-07-17'])], [('regression', {'anchor': [2021, 9, 30], 'interval': 'year', 'count': 3, 'at': [2021, 12, 24]}, ['2021-09-30', '2024-09-30']), ('regression', {'anchor': [2023, 5, 19], 'interval': 'year', 'count': 1, 'at': [2025, 8, 18]}, ['2025-05-19', '2026-05-19']), ('partial-repair probe', {'anchor': [2022, 9, 30], 'interval': 'year', 'count': 3, 'at': [2023, 10, 5]}, ['2022-09-30', '2025-09-30']), ('partial-repair probe', {'anchor': [2022, 4, 19], 'interval': 'year', 'count': 3, 'at': [2023, 9, 9]}, ['2022-04-19', '2025-04-19']), ('boundary control', {'anchor': [2024, 1, 10], 'interval': 'week', 'count': 2, 'at': [2024, 1, 24]}, ['2024-01-24', '2024-02-07']), ('normal control', {'anchor': [2020, 12, 19], 'interval': 'week', 'count': 1, 'at': [2024, 3, 2]}, ['2024-03-02', '2024-03-09']), ('normal control', {'anchor': [2023, 11, 16], 'interval': 'week', 'count': 1, 'at': [2024, 1, 17]}, ['2024-01-11', '2024-01-18']), ('normal control', {'anchor': [2021, 2, 1], 'interval': 'week', 'count': 2, 'at': [2022, 4, 22]}, ['2022-04-11', '2022-04-25']), ('normal control', {'anchor': [2020, 4, 6], 'interval': 'week', 'count': 1, 'at': [2023, 1, 27]}, ['2023-01-23', '2023-01-30'])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), 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 0['2022-02-24', '2022-05-24']['2021-11-24', '2024-11-24']Failed
regression (boundary) 1['2024-01-31', '2025-01-31']['2024-02-29', '2024-03-31']Failed
partial-repair probe 2['2021-08-28', '2021-10-28']['2021-02-28', '2023-02-28']Failed
partial-repair probe 3['2023-07-28', '2023-09-28']['2022-11-28', '2024-11-28']Failed
boundary control 4['2024-01-24', '2024-02-07']['2024-01-24', '2024-02-07']Passed
normal control 5['2020-08-23', '2020-09-13']['2020-08-23', '2020-09-13']Passed
normal control 6['2023-10-27', '2023-11-10']['2023-10-27', '2023-11-10']Passed
normal control 7['2024-10-20', '2024-10-27']['2024-10-20', '2024-10-27']Passed
normal control 8['2022-07-02', '2022-07-16']['2022-07-02', '2022-07-16']Passed

SHA-256 / 2eee847e3a6f31bd86cd74aa562a6a83c9fa4e7348707c33a1cd87197f8fa187

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
import calendar
N = 1
observations = []
def solve(x):
    a = datetime.date(*x['anchor'])
    t = datetime.date(*x['at'])
    def shift(k):
        if x['interval'] == 'week':
            return a + datetime.timedelta(days=7 * x['count'] * k)
        months = k * x['count'] * (12 * x['count'] if x['interval'] == 'year' else 1)
        tot = a.month - 1 + months
        y, m = a.year + tot // 12, tot % 12 + 1
        return datetime.date(y, m, min(a.day, calendar.monthrange(y, m)[1]))
    k = 0
    while shift(k + 1) <= t:
        k += 1
    return [shift(k).isoformat(), shift(k + 1).isoformat()]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'anchor': [2021, 11, 24], 'interval': 'year', 'count': 3, 'at': [2022, 4, 18]}, ['2021-11-24', '2024-11-24']), ('regression (boundary)', {'anchor': [2024, 1, 31], 'interval': 'month', 'count': 1, 'at': [2024, 2, 29]}, ['2024-02-29', '2024-03-31']), ('partial-repair probe', {'anchor': [2021, 2, 28], 'interval': 'year', 'count': 2, 'at': [2021, 8, 29]}, ['2021-02-28', '2023-02-28']), ('partial-repair probe', {'anchor': [2020, 11, 28], 'interval': 'year', 'count': 2, 'at': [2023, 9, 6]}, ['2022-11-28', '2024-11-28']), ('boundary control', {'anchor': [2024, 1, 10], 'interval': 'week', 'count': 2, 'at': [2024, 1, 24]}, ['2024-01-24', '2024-02-07']), ('normal control', {'anchor': [2020, 8, 2], 'interval': 'week', 'count': 3, 'at': [2020, 9, 4]}, ['2020-08-23', '2020-09-13']), ('normal control', {'anchor': [2020, 8, 7], 'interval': 'week', 'count': 2, 'at': [2023, 10, 30]}, ['2023-10-27', '2023-11-10']), ('normal control', {'anchor': [2021, 8, 15], 'interval': 'week', 'count': 1, 'at': [2024, 10, 23]}, ['2024-10-20', '2024-10-27']), ('normal control', {'anchor': [2020, 11, 21], 'interval': 'week', 'count': 2, 'at': [2022, 7, 12]}, ['2022-07-02', '2022-07-16'])], [('regression', {'anchor': [2021, 2, 28], 'interval': 'year', 'count': 2, 'at': [2021, 8, 29]}, ['2021-02-28', '2023-02-28']), ('regression', {'anchor': [2020, 10, 31], 'interval': 'year', 'count': 1, 'at': [2022, 2, 15]}, ['2021-10-31', '2022-10-31']), ('partial-repair probe', {'anchor': [2020, 11, 28], 'interval': 'year', 'count': 2, 'at': [2023, 9, 6]}, ['2022-11-28', '2024-11-28']), ('partial-repair probe', {'anchor': [2023, 3, 31], 'interval': 'year', 'count': 3, 'at': [2024, 8, 8]}, ['2023-03-31', '2026-03-31']), ('boundary control', {'anchor': [2024, 1, 10], 'interval': 'week', 'count': 2, 'at': [2024, 1, 24]}, ['2024-01-24', '2024-02-07']), ('normal control', {'anchor': [2021, 5, 20], 'interval': 'week', 'count': 1, 'at': [2022, 8, 31]}, ['2022-08-25', '2022-09-01']), ('normal control', {'anchor': [2022, 8, 21], 'interval': 'week', 'count': 1, 'at': [2025, 1, 26]}, ['2025-01-26', '2025-02-02']), ('normal control', {'anchor': [2020, 4, 24], 'interval': 'week', 'count': 1, 'at': [2021, 1, 14]}, ['2021-01-08', '2021-01-15']), ('normal control', {'anchor': [2020, 4, 15], 'interval': 'week', 'count': 1, 'at': [2022, 5, 12]}, ['2022-05-11', '2022-05-18'])], [('regression', {'anchor': [2020, 11, 28], 'interval': 'year', 'count': 2, 'at': [2023, 9, 6]}, ['2022-11-28', '2024-11-28']), ('regression', {'anchor': [2023, 10, 31], 'interval': 'month', 'count': 2, 'at': [2024, 2, 3]}, ['2023-12-31', '2024-02-29']), ('partial-repair probe', {'anchor': [2021, 9, 30], 'interval': 'year', 'count': 3, 'at': [2021, 12, 24]}, ['2021-09-30', '2024-09-30']), ('partial-repair probe', {'anchor': [2021, 6, 30], 'interval': 'year', 'count': 3, 'at': [2022, 7, 26]}, ['2021-06-30', '2024-06-30']), ('boundary control', {'anchor': [2024, 1, 10], 'interval': 'week', 'count': 2, 'at': [2024, 1, 24]}, ['2024-01-24', '2024-02-07']), ('normal control', {'anchor': [2021, 3, 2], 'interval': 'week', 'count': 1, 'at': [2023, 4, 10]}, ['2023-04-04', '2023-04-11']), ('normal control', {'anchor': [2023, 4, 28], 'interval': 'week', 'count': 1, 'at': [2024, 7, 31]}, ['2024-07-26', '2024-08-02']), ('normal control', {'anchor': [2020, 1, 18], 'interval': 'week', 'count': 3, 'at': [2021, 11, 30]}, ['2021-11-20', '2021-12-11']), ('normal control', {'anchor': [2020, 2, 8], 'interval': 'week', 'count': 1, 'at': [2021, 4, 15]}, ['2021-04-10', '2021-04-17'])], [('regression', {'anchor': [2023, 3, 31], 'interval': 'year', 'count': 3, 'at': [2024, 8, 8]}, ['2023-03-31', '2026-03-31']), ('regression', {'anchor': [2022, 10, 31], 'interval': 'month', 'count': 2, 'at': [2023, 6, 30]}, ['2023-06-30', '2023-08-31']), ('partial-repair probe', {'anchor': [2023, 12, 31], 'interval': 'year', 'count': 3, 'at': [2026, 4, 8]}, ['2023-12-31', '2026-12-31']), ('partial-repair probe', {'anchor': [2021, 9, 30], 'interval': 'year', 'count': 2, 'at': [2023, 8, 3]}, ['2021-09-30', '2023-09-30']), ('boundary control', {'anchor': [2024, 1, 10], 'interval': 'week', 'count': 2, 'at': [2024, 1, 24]}, ['2024-01-24', '2024-02-07']), ('normal control', {'anchor': [2020, 7, 6], 'interval': 'week', 'count': 2, 'at': [2023, 9, 7]}, ['2023-08-28', '2023-09-11']), ('normal control', {'anchor': [2022, 2, 27], 'interval': 'week', 'count': 1, 'at': [2023, 11, 19]}, ['2023-11-19', '2023-11-26']), ('normal control', {'anchor': [2021, 8, 13], 'interval': 'week', 'count': 1, 'at': [2023, 3, 26]}, ['2023-03-24', '2023-03-31']), ('normal control', {'anchor': [2021, 1, 2], 'interval': 'week', 'count': 2, 'at': [2021, 7, 13]}, ['2021-07-03', '2021-07-17'])], [('regression', {'anchor': [2021, 9, 30], 'interval': 'year', 'count': 3, 'at': [2021, 12, 24]}, ['2021-09-30', '2024-09-30']), ('regression', {'anchor': [2023, 5, 19], 'interval': 'year', 'count': 1, 'at': [2025, 8, 18]}, ['2025-05-19', '2026-05-19']), ('partial-repair probe', {'anchor': [2022, 9, 30], 'interval': 'year', 'count': 3, 'at': [2023, 10, 5]}, ['2022-09-30', '2025-09-30']), ('partial-repair probe', {'anchor': [2022, 4, 19], 'interval': 'year', 'count': 3, 'at': [2023, 9, 9]}, ['2022-04-19', '2025-04-19']), ('boundary control', {'anchor': [2024, 1, 10], 'interval': 'week', 'count': 2, 'at': [2024, 1, 24]}, ['2024-01-24', '2024-02-07']), ('normal control', {'anchor': [2020, 12, 19], 'interval': 'week', 'count': 1, 'at': [2024, 3, 2]}, ['2024-03-02', '2024-03-09']), ('normal control', {'anchor': [2023, 11, 16], 'interval': 'week', 'count': 1, 'at': [2024, 1, 17]}, ['2024-01-11', '2024-01-18']), ('normal control', {'anchor': [2021, 2, 1], 'interval': 'week', 'count': 2, 'at': [2022, 4, 22]}, ['2022-04-11', '2022-04-25']), ('normal control', {'anchor': [2020, 4, 6], 'interval': 'week', 'count': 1, 'at': [2023, 1, 27]}, ['2023-01-23', '2023-01-30'])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), 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 0['2021-11-24', '2030-11-24']['2021-11-24', '2024-11-24']Failed
regression (boundary) 1['2024-02-29', '2024-03-31']['2024-02-29', '2024-03-31']Passed
partial-repair probe 2['2021-02-28', '2025-02-28']['2021-02-28', '2023-02-28']Failed
partial-repair probe 3['2020-11-28', '2024-11-28']['2022-11-28', '2024-11-28']Failed
boundary control 4['2024-01-24', '2024-02-07']['2024-01-24', '2024-02-07']Passed
normal control 5['2020-08-23', '2020-09-13']['2020-08-23', '2020-09-13']Passed
normal control 6['2023-10-27', '2023-11-10']['2023-10-27', '2023-11-10']Passed
normal control 7['2024-10-20', '2024-10-27']['2024-10-20', '2024-10-27']Passed
normal control 8['2022-07-02', '2022-07-16']['2022-07-02', '2022-07-16']Passed

SHA-256 / 3bb43c34c6a5685787d2eba569b7c014d19ac64c475d2575c526c76703532e7d

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 9 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

A deterministic teaching model of a stipulated billing rule. It makes no claim to reproduce any billing provider's exact behaviour and is not billing software. 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:38.960789+00:00.

Case digest / fe7ec2c858732c7b6e399495fc3229699c289692beb7abbcce74393ab05665ef