FA-59731 / Subscription proration billing / Open access
Current billing period containing a date: weekly count multiplier · case 01
Biweekly plans are treated as weekly.
ROOT CAUSE
The interval count is ignored for weekly plans.
THE FAILURE
The interval count is ignored for weekly plans.
Unsuccessful approach: The attempt adds the count instead of multiplying it.
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 * k)
months = k * x['count'] * (12 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 (boundary)', {'anchor': [2024, 1, 10], 'interval': 'week', 'count': 2, 'at': [2024, 1, 24]}, ['2024-01-24', '2024-02-07']), ('regression', {'anchor': [2020, 8, 2], 'interval': 'week', 'count': 3, 'at': [2020, 9, 4]}, ['2020-08-23', '2020-09-13']), ('partial-repair probe', {'anchor': [2020, 8, 7], 'interval': 'week', 'count': 2, 'at': [2023, 10, 30]}, ['2023-10-27', '2023-11-10']), ('partial-repair probe', {'anchor': [2020, 11, 21], 'interval': 'week', 'count': 2, 'at': [2022, 7, 12]}, ['2022-07-02', '2022-07-16']), ('boundary control', {'anchor': [2024, 1, 31], 'interval': 'month', 'count': 1, 'at': [2024, 2, 29]}, ['2024-02-29', '2024-03-31']), ('normal control', {'anchor': [2020, 10, 31], 'interval': 'year', 'count': 1, 'at': [2022, 2, 15]}, ['2021-10-31', '2022-10-31']), ('normal control', {'anchor': [2023, 10, 31], 'interval': 'month', 'count': 2, 'at': [2024, 2, 3]}, ['2023-12-31', '2024-02-29']), ('normal control', {'anchor': [2022, 10, 31], 'interval': 'month', 'count': 2, 'at': [2023, 6, 30]}, ['2023-06-30', '2023-08-31']), ('normal control', {'anchor': [2023, 5, 19], 'interval': 'year', 'count': 1, 'at': [2025, 8, 18]}, ['2025-05-19', '2026-05-19'])], [('regression', {'anchor': [2020, 8, 2], 'interval': 'week', 'count': 3, 'at': [2020, 9, 4]}, ['2020-08-23', '2020-09-13']), ('regression', {'anchor': [2020, 8, 7], 'interval': 'week', 'count': 2, 'at': [2023, 10, 30]}, ['2023-10-27', '2023-11-10']), ('partial-repair probe', {'anchor': [2020, 11, 21], 'interval': 'week', 'count': 2, 'at': [2022, 7, 12]}, ['2022-07-02', '2022-07-16']), ('partial-repair probe', {'anchor': [2020, 1, 18], 'interval': 'week', 'count': 3, 'at': [2021, 11, 30]}, ['2021-11-20', '2021-12-11']), ('boundary control', {'anchor': [2024, 1, 31], 'interval': 'month', 'count': 1, 'at': [2024, 2, 29]}, ['2024-02-29', '2024-03-31']), ('normal control', {'anchor': [2021, 11, 24], 'interval': 'year', 'count': 3, 'at': [2022, 4, 18]}, ['2021-11-24', '2024-11-24']), ('normal control', {'anchor': [2021, 2, 28], 'interval': 'year', 'count': 2, 'at': [2021, 8, 29]}, ['2021-02-28', '2023-02-28']), ('normal control', {'anchor': [2020, 11, 28], 'interval': 'year', 'count': 2, 'at': [2023, 9, 6]}, ['2022-11-28', '2024-11-28']), ('normal control', {'anchor': [2023, 12, 31], 'interval': 'month', 'count': 1, 'at': [2024, 7, 11]}, ['2024-06-30', '2024-07-31'])], [('regression', {'anchor': [2020, 8, 7], 'interval': 'week', 'count': 2, 'at': [2023, 10, 30]}, ['2023-10-27', '2023-11-10']), ('regression', {'anchor': [2020, 11, 21], 'interval': 'week', 'count': 2, 'at': [2022, 7, 12]}, ['2022-07-02', '2022-07-16']), ('partial-repair probe', {'anchor': [2020, 1, 18], 'interval': 'week', 'count': 3, 'at': [2021, 11, 30]}, ['2021-11-20', '2021-12-11']), ('partial-repair probe', {'anchor': [2020, 7, 6], 'interval': 'week', 'count': 2, 'at': [2023, 9, 7]}, ['2023-08-28', '2023-09-11']), ('boundary control', {'anchor': [2024, 1, 31], 'interval': 'month', 'count': 1, 'at': [2024, 2, 29]}, ['2024-02-29', '2024-03-31']), ('normal control', {'anchor': [2020, 2, 20], 'interval': 'month', 'count': 1, 'at': [2022, 12, 10]}, ['2022-11-20', '2022-12-20']), ('normal control', {'anchor': [2021, 8, 15], 'interval': 'week', 'count': 1, 'at': [2024, 10, 23]}, ['2024-10-20', '2024-10-27']), ('normal control', {'anchor': [2023, 3, 14], 'interval': 'month', 'count': 3, 'at': [2026, 4, 3]}, ['2026-03-14', '2026-06-14']), ('normal control', {'anchor': [2021, 8, 31], 'interval': 'year', 'count': 1, 'at': [2022, 7, 27]}, ['2021-08-31', '2022-08-31'])], [('regression', {'anchor': [2020, 11, 21], 'interval': 'week', 'count': 2, 'at': [2022, 7, 12]}, ['2022-07-02', '2022-07-16']), ('regression', {'anchor': [2020, 1, 18], 'interval': 'week', 'count': 3, 'at': [2021, 11, 30]}, ['2021-11-20', '2021-12-11']), ('partial-repair probe', {'anchor': [2021, 1, 2], 'interval': 'week', 'count': 2, 'at': [2021, 7, 13]}, ['2021-07-03', '2021-07-17']), ('partial-repair probe', {'anchor': [2021, 2, 1], 'interval': 'week', 'count': 2, 'at': [2022, 4, 22]}, ['2022-04-11', '2022-04-25']), ('boundary control', {'anchor': [2024, 1, 31], 'interval': 'month', 'count': 1, 'at': [2024, 2, 29]}, ['2024-02-29', '2024-03-31']), ('normal control', {'anchor': [2022, 10, 31], 'interval': 'month', 'count': 1, 'at': [2023, 11, 30]}, ['2023-11-30', '2023-12-31']), ('normal control', {'anchor': [2021, 5, 20], 'interval': 'week', 'count': 1, 'at': [2022, 8, 31]}, ['2022-08-25', '2022-09-01']), ('normal control', {'anchor': [2022, 6, 30], 'interval': 'month', 'count': 1, 'at': [2023, 6, 1]}, ['2023-05-30', '2023-06-30']), ('normal control', {'anchor': [2022, 12, 6], 'interval': 'month', 'count': 1, 'at': [2025, 6, 30]}, ['2025-06-06', '2025-07-06'])], [('regression', {'anchor': [2020, 1, 18], 'interval': 'week', 'count': 3, 'at': [2021, 11, 30]}, ['2021-11-20', '2021-12-11']), ('regression', {'anchor': [2020, 7, 6], 'interval': 'week', 'count': 2, 'at': [2023, 9, 7]}, ['2023-08-28', '2023-09-11']), ('partial-repair probe', {'anchor': [2020, 12, 28], 'interval': 'week', 'count': 2, 'at': [2021, 6, 22]}, ['2021-06-14', '2021-06-28']), ('partial-repair probe', {'anchor': [2023, 12, 20], 'interval': 'week', 'count': 3, 'at': [2026, 5, 31]}, ['2026-05-20', '2026-06-10']), ('boundary control', {'anchor': [2024, 1, 31], 'interval': 'month', 'count': 1, 'at': [2024, 2, 29]}, ['2024-02-29', '2024-03-31']), ('normal control', {'anchor': [2022, 8, 21], 'interval': 'week', 'count': 1, 'at': [2025, 1, 26]}, ['2025-01-26', '2025-02-02']), ('normal control', {'anchor': [2021, 4, 30], 'interval': 'month', 'count': 1, 'at': [2023, 4, 25]}, ['2023-03-30', '2023-04-30']), ('normal control', {'anchor': [2020, 4, 24], 'interval': 'week', 'count': 1, 'at': [2021, 1, 14]}, ['2021-01-08', '2021-01-15']), ('normal control', {'anchor': [2021, 7, 13], 'interval': 'year', 'count': 1, 'at': [2021, 11, 5]}, ['2021-07-13', '2022-07-13'])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression (boundary) 0 | ['2024-01-24', '2024-01-31'] | ['2024-01-24', '2024-02-07'] | Failed |
| regression 1 | ['2020-08-30', '2020-09-06'] | ['2020-08-23', '2020-09-13'] | Failed |
| partial-repair probe 2 | ['2023-10-27', '2023-11-03'] | ['2023-10-27', '2023-11-10'] | Failed |
| partial-repair probe 3 | ['2022-07-09', '2022-07-16'] | ['2022-07-02', '2022-07-16'] | Failed |
| boundary control 4 | ['2024-02-29', '2024-03-31'] | ['2024-02-29', '2024-03-31'] | Passed |
| normal control 5 | ['2021-10-31', '2022-10-31'] | ['2021-10-31', '2022-10-31'] | Passed |
| normal control 6 | ['2023-12-31', '2024-02-29'] | ['2023-12-31', '2024-02-29'] | Passed |
| normal control 7 | ['2023-06-30', '2023-08-31'] | ['2023-06-30', '2023-08-31'] | Passed |
| normal control 8 | ['2025-05-19', '2026-05-19'] | ['2025-05-19', '2026-05-19'] | Passed |
SHA-256 / d4beef38497d4fec10b29d56f75aaf59aadf6fdc20175294de374269afc2c5a5
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 - 1))
months = k * x['count'] * (12 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 (boundary)', {'anchor': [2024, 1, 10], 'interval': 'week', 'count': 2, 'at': [2024, 1, 24]}, ['2024-01-24', '2024-02-07']), ('regression', {'anchor': [2020, 8, 2], 'interval': 'week', 'count': 3, 'at': [2020, 9, 4]}, ['2020-08-23', '2020-09-13']), ('partial-repair probe', {'anchor': [2020, 8, 7], 'interval': 'week', 'count': 2, 'at': [2023, 10, 30]}, ['2023-10-27', '2023-11-10']), ('partial-repair probe', {'anchor': [2020, 11, 21], 'interval': 'week', 'count': 2, 'at': [2022, 7, 12]}, ['2022-07-02', '2022-07-16']), ('boundary control', {'anchor': [2024, 1, 31], 'interval': 'month', 'count': 1, 'at': [2024, 2, 29]}, ['2024-02-29', '2024-03-31']), ('normal control', {'anchor': [2020, 10, 31], 'interval': 'year', 'count': 1, 'at': [2022, 2, 15]}, ['2021-10-31', '2022-10-31']), ('normal control', {'anchor': [2023, 10, 31], 'interval': 'month', 'count': 2, 'at': [2024, 2, 3]}, ['2023-12-31', '2024-02-29']), ('normal control', {'anchor': [2022, 10, 31], 'interval': 'month', 'count': 2, 'at': [2023, 6, 30]}, ['2023-06-30', '2023-08-31']), ('normal control', {'anchor': [2023, 5, 19], 'interval': 'year', 'count': 1, 'at': [2025, 8, 18]}, ['2025-05-19', '2026-05-19'])], [('regression', {'anchor': [2020, 8, 2], 'interval': 'week', 'count': 3, 'at': [2020, 9, 4]}, ['2020-08-23', '2020-09-13']), ('regression', {'anchor': [2020, 8, 7], 'interval': 'week', 'count': 2, 'at': [2023, 10, 30]}, ['2023-10-27', '2023-11-10']), ('partial-repair probe', {'anchor': [2020, 11, 21], 'interval': 'week', 'count': 2, 'at': [2022, 7, 12]}, ['2022-07-02', '2022-07-16']), ('partial-repair probe', {'anchor': [2020, 1, 18], 'interval': 'week', 'count': 3, 'at': [2021, 11, 30]}, ['2021-11-20', '2021-12-11']), ('boundary control', {'anchor': [2024, 1, 31], 'interval': 'month', 'count': 1, 'at': [2024, 2, 29]}, ['2024-02-29', '2024-03-31']), ('normal control', {'anchor': [2021, 11, 24], 'interval': 'year', 'count': 3, 'at': [2022, 4, 18]}, ['2021-11-24', '2024-11-24']), ('normal control', {'anchor': [2021, 2, 28], 'interval': 'year', 'count': 2, 'at': [2021, 8, 29]}, ['2021-02-28', '2023-02-28']), ('normal control', {'anchor': [2020, 11, 28], 'interval': 'year', 'count': 2, 'at': [2023, 9, 6]}, ['2022-11-28', '2024-11-28']), ('normal control', {'anchor': [2023, 12, 31], 'interval': 'month', 'count': 1, 'at': [2024, 7, 11]}, ['2024-06-30', '2024-07-31'])], [('regression', {'anchor': [2020, 8, 7], 'interval': 'week', 'count': 2, 'at': [2023, 10, 30]}, ['2023-10-27', '2023-11-10']), ('regression', {'anchor': [2020, 11, 21], 'interval': 'week', 'count': 2, 'at': [2022, 7, 12]}, ['2022-07-02', '2022-07-16']), ('partial-repair probe', {'anchor': [2020, 1, 18], 'interval': 'week', 'count': 3, 'at': [2021, 11, 30]}, ['2021-11-20', '2021-12-11']), ('partial-repair probe', {'anchor': [2020, 7, 6], 'interval': 'week', 'count': 2, 'at': [2023, 9, 7]}, ['2023-08-28', '2023-09-11']), ('boundary control', {'anchor': [2024, 1, 31], 'interval': 'month', 'count': 1, 'at': [2024, 2, 29]}, ['2024-02-29', '2024-03-31']), ('normal control', {'anchor': [2020, 2, 20], 'interval': 'month', 'count': 1, 'at': [2022, 12, 10]}, ['2022-11-20', '2022-12-20']), ('normal control', {'anchor': [2021, 8, 15], 'interval': 'week', 'count': 1, 'at': [2024, 10, 23]}, ['2024-10-20', '2024-10-27']), ('normal control', {'anchor': [2023, 3, 14], 'interval': 'month', 'count': 3, 'at': [2026, 4, 3]}, ['2026-03-14', '2026-06-14']), ('normal control', {'anchor': [2021, 8, 31], 'interval': 'year', 'count': 1, 'at': [2022, 7, 27]}, ['2021-08-31', '2022-08-31'])], [('regression', {'anchor': [2020, 11, 21], 'interval': 'week', 'count': 2, 'at': [2022, 7, 12]}, ['2022-07-02', '2022-07-16']), ('regression', {'anchor': [2020, 1, 18], 'interval': 'week', 'count': 3, 'at': [2021, 11, 30]}, ['2021-11-20', '2021-12-11']), ('partial-repair probe', {'anchor': [2021, 1, 2], 'interval': 'week', 'count': 2, 'at': [2021, 7, 13]}, ['2021-07-03', '2021-07-17']), ('partial-repair probe', {'anchor': [2021, 2, 1], 'interval': 'week', 'count': 2, 'at': [2022, 4, 22]}, ['2022-04-11', '2022-04-25']), ('boundary control', {'anchor': [2024, 1, 31], 'interval': 'month', 'count': 1, 'at': [2024, 2, 29]}, ['2024-02-29', '2024-03-31']), ('normal control', {'anchor': [2022, 10, 31], 'interval': 'month', 'count': 1, 'at': [2023, 11, 30]}, ['2023-11-30', '2023-12-31']), ('normal control', {'anchor': [2021, 5, 20], 'interval': 'week', 'count': 1, 'at': [2022, 8, 31]}, ['2022-08-25', '2022-09-01']), ('normal control', {'anchor': [2022, 6, 30], 'interval': 'month', 'count': 1, 'at': [2023, 6, 1]}, ['2023-05-30', '2023-06-30']), ('normal control', {'anchor': [2022, 12, 6], 'interval': 'month', 'count': 1, 'at': [2025, 6, 30]}, ['2025-06-06', '2025-07-06'])], [('regression', {'anchor': [2020, 1, 18], 'interval': 'week', 'count': 3, 'at': [2021, 11, 30]}, ['2021-11-20', '2021-12-11']), ('regression', {'anchor': [2020, 7, 6], 'interval': 'week', 'count': 2, 'at': [2023, 9, 7]}, ['2023-08-28', '2023-09-11']), ('partial-repair probe', {'anchor': [2020, 12, 28], 'interval': 'week', 'count': 2, 'at': [2021, 6, 22]}, ['2021-06-14', '2021-06-28']), ('partial-repair probe', {'anchor': [2023, 12, 20], 'interval': 'week', 'count': 3, 'at': [2026, 5, 31]}, ['2026-05-20', '2026-06-10']), ('boundary control', {'anchor': [2024, 1, 31], 'interval': 'month', 'count': 1, 'at': [2024, 2, 29]}, ['2024-02-29', '2024-03-31']), ('normal control', {'anchor': [2022, 8, 21], 'interval': 'week', 'count': 1, 'at': [2025, 1, 26]}, ['2025-01-26', '2025-02-02']), ('normal control', {'anchor': [2021, 4, 30], 'interval': 'month', 'count': 1, 'at': [2023, 4, 25]}, ['2023-03-30', '2023-04-30']), ('normal control', {'anchor': [2020, 4, 24], 'interval': 'week', 'count': 1, 'at': [2021, 1, 14]}, ['2021-01-08', '2021-01-15']), ('normal control', {'anchor': [2021, 7, 13], 'interval': 'year', 'count': 1, 'at': [2021, 11, 5]}, ['2021-07-13', '2022-07-13'])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression (boundary) 0 | ['2024-01-24', '2024-01-31'] | ['2024-01-24', '2024-02-07'] | Failed |
| regression 1 | ['2020-08-30', '2020-09-06'] | ['2020-08-23', '2020-09-13'] | Failed |
| partial-repair probe 2 | ['2023-10-27', '2023-11-03'] | ['2023-10-27', '2023-11-10'] | Failed |
| partial-repair probe 3 | ['2022-07-09', '2022-07-16'] | ['2022-07-02', '2022-07-16'] | Failed |
| boundary control 4 | ['2024-02-29', '2024-03-31'] | ['2024-02-29', '2024-03-31'] | Passed |
| normal control 5 | ['2021-10-31', '2022-10-31'] | ['2021-10-31', '2022-10-31'] | Passed |
| normal control 6 | ['2023-12-31', '2024-02-29'] | ['2023-12-31', '2024-02-29'] | Passed |
| normal control 7 | ['2023-06-30', '2023-08-31'] | ['2023-06-30', '2023-08-31'] | Passed |
| normal control 8 | ['2025-05-19', '2026-05-19'] | ['2025-05-19', '2026-05-19'] | Passed |
SHA-256 / 021f46f77a74e3ca11066d39e9bcf1f7abb942141aa0e0e7549be3b4c20b9398
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:39.004886+00:00.
Case digest / d8d425aba35d5312898a085b6bc6e612f7182ef7f650cb9e727338ef0a3f1275