FAILURE MAP
← Case archive

FA-59356 / Subscription proration billing / Open access

Daily plan-change proration: downgrade credit balance · case 01

Downgrades produce a negative amount due on the invoice.

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

ROOT CAUSE

A negative net is reported as amount due instead of becoming a customer credit balance.

VERIFIED REPAIR

Restore the contract rule at the downgrade credit balance step: use `return [credit, charge, max(0, net), max(0, -net)]`.

Unsuccessful approach: The attempt floors the amount due but discards the credit entirely.

Case contract

Input {old, new prices per period, start, end (exclusive), change} dates with start <= change < end. Remaining days = end - change; period days = end - start. Credit = old*remaining/period and charge = new*remaining/period, each rounded half-up. Net = charge - credit; a positive net is due now, a negative net becomes a credit balance. Return [credit, charge, amount_due, credit_balance].

Why this case matters

Mid-cycle plan changes must credit unused time on the old plan and charge the new plan for the same days.

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):
    s = datetime.date(*x['start'])
    e = datetime.date(*x['end'])
    c = datetime.date(*x['change'])
    total = (e - s).days
    remaining = (e - c).days
    def pr(p):
        return (p * remaining * 2 + total) // (2 * total)
    credit = pr(x['old'])
    charge = pr(x['new'])
    net = charge - credit
    return [credit, charge, net, 0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'old': 12063, 'new': 1999, 'start': [2024, 10, 16], 'end': [2024, 11, 14], 'change': [2024, 11, 2]}, [4992, 827, 0, 4165]), ('regression', {'old': 34933, 'new': 4900, 'start': [2024, 12, 28], 'end': [2025, 1, 28], 'change': [2025, 1, 22]}, [6761, 948, 0, 5813]), ('partial-repair probe', {'old': 38640, 'new': 36658, 'start': [2024, 12, 23], 'end': [2025, 1, 22], 'change': [2025, 1, 21]}, [1288, 1222, 0, 66]), ('partial-repair probe', {'old': 33928, 'new': 9900, 'start': [2025, 3, 24], 'end': [2025, 4, 24], 'change': [2025, 4, 16]}, [8756, 2555, 0, 6201]), ('normal control', {'old': 999, 'new': 1999, 'start': [2023, 10, 16], 'end': [2023, 11, 13], 'change': [2023, 11, 8]}, [178, 357, 179, 0]), ('normal control', {'old': 999, 'new': 1999, 'start': [2024, 9, 16], 'end': [2024, 12, 15], 'change': [2024, 12, 10]}, [56, 111, 55, 0]), ('normal control', {'old': 4900, 'new': 8489, 'start': [2024, 3, 22], 'end': [2024, 6, 20], 'change': [2024, 4, 18]}, [3430, 5942, 2512, 0]), ('normal control', {'old': 4900, 'new': 9900, 'start': [2024, 1, 10], 'end': [2024, 4, 9], 'change': [2024, 3, 7]}, [1797, 3630, 1833, 0])], [('regression', {'old': 34933, 'new': 4900, 'start': [2024, 12, 28], 'end': [2025, 1, 28], 'change': [2025, 1, 22]}, [6761, 948, 0, 5813]), ('regression', {'old': 38640, 'new': 36658, 'start': [2024, 12, 23], 'end': [2025, 1, 22], 'change': [2025, 1, 21]}, [1288, 1222, 0, 66]), ('partial-repair probe', {'old': 33928, 'new': 9900, 'start': [2025, 3, 24], 'end': [2025, 4, 24], 'change': [2025, 4, 16]}, [8756, 2555, 0, 6201]), ('partial-repair probe', {'old': 6384, 'new': 4900, 'start': [2023, 3, 23], 'end': [2023, 4, 23], 'change': [2023, 4, 13]}, [2059, 1581, 0, 478]), ('normal control', {'old': 4900, 'new': 9900, 'start': [2024, 6, 18], 'end': [2024, 7, 18], 'change': [2024, 6, 21]}, [4410, 8910, 4500, 0]), ('normal control', {'old': 999, 'new': 4900, 'start': [2025, 1, 22], 'end': [2025, 4, 22], 'change': [2025, 3, 8]}, [500, 2450, 1950, 0]), ('normal control', {'old': 7276, 'new': 43371, 'start': [2024, 5, 21], 'end': [2024, 8, 19], 'change': [2024, 6, 13]}, [5417, 32287, 26870, 0]), ('normal control', {'old': 4900, 'new': 14973, 'start': [2025, 4, 11], 'end': [2025, 5, 10], 'change': [2025, 4, 17]}, [3886, 11875, 7989, 0])], [('regression', {'old': 38640, 'new': 36658, 'start': [2024, 12, 23], 'end': [2025, 1, 22], 'change': [2025, 1, 21]}, [1288, 1222, 0, 66]), ('regression', {'old': 33928, 'new': 9900, 'start': [2025, 3, 24], 'end': [2025, 4, 24], 'change': [2025, 4, 16]}, [8756, 2555, 0, 6201]), ('partial-repair probe', {'old': 6384, 'new': 4900, 'start': [2023, 3, 23], 'end': [2023, 4, 23], 'change': [2023, 4, 13]}, [2059, 1581, 0, 478]), ('partial-repair probe', {'old': 23223, 'new': 4900, 'start': [2025, 2, 5], 'end': [2025, 3, 8], 'change': [2025, 2, 9]}, [20226, 4268, 0, 15958]), ('normal control', {'old': 4900, 'new': 9900, 'start': [2024, 11, 22], 'end': [2024, 12, 21], 'change': [2024, 12, 19]}, [338, 683, 345, 0]), ('normal control', {'old': 4900, 'new': 46132, 'start': [2024, 4, 13], 'end': [2024, 5, 12], 'change': [2024, 4, 30]}, [2028, 19089, 17061, 0]), ('normal control', {'old': 1999, 'new': 4900, 'start': [2023, 10, 12], 'end': [2024, 10, 11], 'change': [2024, 2, 28]}, [1238, 3034, 1796, 0]), ('normal control', {'old': 999, 'new': 9900, 'start': [2025, 5, 5], 'end': [2025, 6, 3], 'change': [2025, 5, 20]}, [482, 4779, 4297, 0])], [('regression', {'old': 33928, 'new': 9900, 'start': [2025, 3, 24], 'end': [2025, 4, 24], 'change': [2025, 4, 16]}, [8756, 2555, 0, 6201]), ('regression', {'old': 6384, 'new': 4900, 'start': [2023, 3, 23], 'end': [2023, 4, 23], 'change': [2023, 4, 13]}, [2059, 1581, 0, 478]), ('partial-repair probe', {'old': 4900, 'new': 1999, 'start': [2023, 7, 16], 'end': [2023, 10, 14], 'change': [2023, 9, 2]}, [2287, 933, 0, 1354]), ('partial-repair probe', {'old': 17701, 'new': 4900, 'start': [2024, 7, 1], 'end': [2024, 8, 1], 'change': [2024, 7, 6]}, [14846, 4110, 0, 10736]), ('normal control', {'old': 27165, 'new': 30410, 'start': [2023, 10, 29], 'end': [2024, 1, 27], 'change': [2023, 12, 28]}, [9055, 10137, 1082, 0]), ('normal control', {'old': 1999, 'new': 1999, 'start': [2024, 4, 24], 'end': [2024, 5, 25], 'change': [2024, 5, 23]}, [129, 129, 0, 0]), ('normal control', {'old': 1999, 'new': 9900, 'start': [2024, 7, 18], 'end': [2024, 8, 18], 'change': [2024, 8, 1]}, [1096, 5429, 4333, 0]), ('normal control', {'old': 1999, 'new': 1999, 'start': [2025, 5, 29], 'end': [2025, 6, 28], 'change': [2025, 6, 7]}, [1399, 1399, 0, 0])], [('regression', {'old': 6384, 'new': 4900, 'start': [2023, 3, 23], 'end': [2023, 4, 23], 'change': [2023, 4, 13]}, [2059, 1581, 0, 478]), ('regression', {'old': 23223, 'new': 4900, 'start': [2025, 2, 5], 'end': [2025, 3, 8], 'change': [2025, 2, 9]}, [20226, 4268, 0, 15958]), ('partial-repair probe', {'old': 41031, 'new': 1999, 'start': [2023, 6, 12], 'end': [2023, 7, 13], 'change': [2023, 7, 6]}, [9265, 451, 0, 8814]), ('partial-repair probe', {'old': 46901, 'new': 1999, 'start': [2023, 10, 17], 'end': [2023, 11, 15], 'change': [2023, 10, 28]}, [29111, 1241, 0, 27870]), ('normal control', {'old': 999, 'new': 4900, 'start': [2025, 5, 24], 'end': [2025, 6, 24], 'change': [2025, 5, 24]}, [999, 4900, 3901, 0]), ('normal control', {'old': 999, 'new': 9900, 'start': [2023, 10, 10], 'end': [2024, 10, 9], 'change': [2024, 4, 29]}, [446, 4421, 3975, 0]), ('normal control', {'old': 4900, 'new': 4900, 'start': [2024, 11, 23], 'end': [2025, 11, 24], 'change': [2025, 7, 22]}, [1673, 1673, 0, 0]), ('normal control', {'old': 1999, 'new': 1999, 'start': [2025, 3, 22], 'end': [2025, 6, 20], 'change': [2025, 5, 23]}, [622, 622, 0, 0])]]
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[4992, 827, -4165, 0][4992, 827, 0, 4165]Failed
regression 1[6761, 948, -5813, 0][6761, 948, 0, 5813]Failed
partial-repair probe 2[1288, 1222, -66, 0][1288, 1222, 0, 66]Failed
partial-repair probe 3[8756, 2555, -6201, 0][8756, 2555, 0, 6201]Failed
normal control 4[178, 357, 179, 0][178, 357, 179, 0]Passed
normal control 5[56, 111, 55, 0][56, 111, 55, 0]Passed
normal control 6[3430, 5942, 2512, 0][3430, 5942, 2512, 0]Passed
normal control 7[1797, 3630, 1833, 0][1797, 3630, 1833, 0]Passed

SHA-256 / 45cd59959ccb5cd5aa936683d669c733d9e4442fdf73c7040405f0da869700db

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):
    s = datetime.date(*x['start'])
    e = datetime.date(*x['end'])
    c = datetime.date(*x['change'])
    total = (e - s).days
    remaining = (e - c).days
    def pr(p):
        return (p * remaining * 2 + total) // (2 * total)
    credit = pr(x['old'])
    charge = pr(x['new'])
    net = charge - credit
    return [credit, charge, max(0, net), 0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'old': 12063, 'new': 1999, 'start': [2024, 10, 16], 'end': [2024, 11, 14], 'change': [2024, 11, 2]}, [4992, 827, 0, 4165]), ('regression', {'old': 34933, 'new': 4900, 'start': [2024, 12, 28], 'end': [2025, 1, 28], 'change': [2025, 1, 22]}, [6761, 948, 0, 5813]), ('partial-repair probe', {'old': 38640, 'new': 36658, 'start': [2024, 12, 23], 'end': [2025, 1, 22], 'change': [2025, 1, 21]}, [1288, 1222, 0, 66]), ('partial-repair probe', {'old': 33928, 'new': 9900, 'start': [2025, 3, 24], 'end': [2025, 4, 24], 'change': [2025, 4, 16]}, [8756, 2555, 0, 6201]), ('normal control', {'old': 999, 'new': 1999, 'start': [2023, 10, 16], 'end': [2023, 11, 13], 'change': [2023, 11, 8]}, [178, 357, 179, 0]), ('normal control', {'old': 999, 'new': 1999, 'start': [2024, 9, 16], 'end': [2024, 12, 15], 'change': [2024, 12, 10]}, [56, 111, 55, 0]), ('normal control', {'old': 4900, 'new': 8489, 'start': [2024, 3, 22], 'end': [2024, 6, 20], 'change': [2024, 4, 18]}, [3430, 5942, 2512, 0]), ('normal control', {'old': 4900, 'new': 9900, 'start': [2024, 1, 10], 'end': [2024, 4, 9], 'change': [2024, 3, 7]}, [1797, 3630, 1833, 0])], [('regression', {'old': 34933, 'new': 4900, 'start': [2024, 12, 28], 'end': [2025, 1, 28], 'change': [2025, 1, 22]}, [6761, 948, 0, 5813]), ('regression', {'old': 38640, 'new': 36658, 'start': [2024, 12, 23], 'end': [2025, 1, 22], 'change': [2025, 1, 21]}, [1288, 1222, 0, 66]), ('partial-repair probe', {'old': 33928, 'new': 9900, 'start': [2025, 3, 24], 'end': [2025, 4, 24], 'change': [2025, 4, 16]}, [8756, 2555, 0, 6201]), ('partial-repair probe', {'old': 6384, 'new': 4900, 'start': [2023, 3, 23], 'end': [2023, 4, 23], 'change': [2023, 4, 13]}, [2059, 1581, 0, 478]), ('normal control', {'old': 4900, 'new': 9900, 'start': [2024, 6, 18], 'end': [2024, 7, 18], 'change': [2024, 6, 21]}, [4410, 8910, 4500, 0]), ('normal control', {'old': 999, 'new': 4900, 'start': [2025, 1, 22], 'end': [2025, 4, 22], 'change': [2025, 3, 8]}, [500, 2450, 1950, 0]), ('normal control', {'old': 7276, 'new': 43371, 'start': [2024, 5, 21], 'end': [2024, 8, 19], 'change': [2024, 6, 13]}, [5417, 32287, 26870, 0]), ('normal control', {'old': 4900, 'new': 14973, 'start': [2025, 4, 11], 'end': [2025, 5, 10], 'change': [2025, 4, 17]}, [3886, 11875, 7989, 0])], [('regression', {'old': 38640, 'new': 36658, 'start': [2024, 12, 23], 'end': [2025, 1, 22], 'change': [2025, 1, 21]}, [1288, 1222, 0, 66]), ('regression', {'old': 33928, 'new': 9900, 'start': [2025, 3, 24], 'end': [2025, 4, 24], 'change': [2025, 4, 16]}, [8756, 2555, 0, 6201]), ('partial-repair probe', {'old': 6384, 'new': 4900, 'start': [2023, 3, 23], 'end': [2023, 4, 23], 'change': [2023, 4, 13]}, [2059, 1581, 0, 478]), ('partial-repair probe', {'old': 23223, 'new': 4900, 'start': [2025, 2, 5], 'end': [2025, 3, 8], 'change': [2025, 2, 9]}, [20226, 4268, 0, 15958]), ('normal control', {'old': 4900, 'new': 9900, 'start': [2024, 11, 22], 'end': [2024, 12, 21], 'change': [2024, 12, 19]}, [338, 683, 345, 0]), ('normal control', {'old': 4900, 'new': 46132, 'start': [2024, 4, 13], 'end': [2024, 5, 12], 'change': [2024, 4, 30]}, [2028, 19089, 17061, 0]), ('normal control', {'old': 1999, 'new': 4900, 'start': [2023, 10, 12], 'end': [2024, 10, 11], 'change': [2024, 2, 28]}, [1238, 3034, 1796, 0]), ('normal control', {'old': 999, 'new': 9900, 'start': [2025, 5, 5], 'end': [2025, 6, 3], 'change': [2025, 5, 20]}, [482, 4779, 4297, 0])], [('regression', {'old': 33928, 'new': 9900, 'start': [2025, 3, 24], 'end': [2025, 4, 24], 'change': [2025, 4, 16]}, [8756, 2555, 0, 6201]), ('regression', {'old': 6384, 'new': 4900, 'start': [2023, 3, 23], 'end': [2023, 4, 23], 'change': [2023, 4, 13]}, [2059, 1581, 0, 478]), ('partial-repair probe', {'old': 4900, 'new': 1999, 'start': [2023, 7, 16], 'end': [2023, 10, 14], 'change': [2023, 9, 2]}, [2287, 933, 0, 1354]), ('partial-repair probe', {'old': 17701, 'new': 4900, 'start': [2024, 7, 1], 'end': [2024, 8, 1], 'change': [2024, 7, 6]}, [14846, 4110, 0, 10736]), ('normal control', {'old': 27165, 'new': 30410, 'start': [2023, 10, 29], 'end': [2024, 1, 27], 'change': [2023, 12, 28]}, [9055, 10137, 1082, 0]), ('normal control', {'old': 1999, 'new': 1999, 'start': [2024, 4, 24], 'end': [2024, 5, 25], 'change': [2024, 5, 23]}, [129, 129, 0, 0]), ('normal control', {'old': 1999, 'new': 9900, 'start': [2024, 7, 18], 'end': [2024, 8, 18], 'change': [2024, 8, 1]}, [1096, 5429, 4333, 0]), ('normal control', {'old': 1999, 'new': 1999, 'start': [2025, 5, 29], 'end': [2025, 6, 28], 'change': [2025, 6, 7]}, [1399, 1399, 0, 0])], [('regression', {'old': 6384, 'new': 4900, 'start': [2023, 3, 23], 'end': [2023, 4, 23], 'change': [2023, 4, 13]}, [2059, 1581, 0, 478]), ('regression', {'old': 23223, 'new': 4900, 'start': [2025, 2, 5], 'end': [2025, 3, 8], 'change': [2025, 2, 9]}, [20226, 4268, 0, 15958]), ('partial-repair probe', {'old': 41031, 'new': 1999, 'start': [2023, 6, 12], 'end': [2023, 7, 13], 'change': [2023, 7, 6]}, [9265, 451, 0, 8814]), ('partial-repair probe', {'old': 46901, 'new': 1999, 'start': [2023, 10, 17], 'end': [2023, 11, 15], 'change': [2023, 10, 28]}, [29111, 1241, 0, 27870]), ('normal control', {'old': 999, 'new': 4900, 'start': [2025, 5, 24], 'end': [2025, 6, 24], 'change': [2025, 5, 24]}, [999, 4900, 3901, 0]), ('normal control', {'old': 999, 'new': 9900, 'start': [2023, 10, 10], 'end': [2024, 10, 9], 'change': [2024, 4, 29]}, [446, 4421, 3975, 0]), ('normal control', {'old': 4900, 'new': 4900, 'start': [2024, 11, 23], 'end': [2025, 11, 24], 'change': [2025, 7, 22]}, [1673, 1673, 0, 0]), ('normal control', {'old': 1999, 'new': 1999, 'start': [2025, 3, 22], 'end': [2025, 6, 20], 'change': [2025, 5, 23]}, [622, 622, 0, 0])]]
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[4992, 827, 0, 0][4992, 827, 0, 4165]Failed
regression 1[6761, 948, 0, 0][6761, 948, 0, 5813]Failed
partial-repair probe 2[1288, 1222, 0, 0][1288, 1222, 0, 66]Failed
partial-repair probe 3[8756, 2555, 0, 0][8756, 2555, 0, 6201]Failed
normal control 4[178, 357, 179, 0][178, 357, 179, 0]Passed
normal control 5[56, 111, 55, 0][56, 111, 55, 0]Passed
normal control 6[3430, 5942, 2512, 0][3430, 5942, 2512, 0]Passed
normal control 7[1797, 3630, 1833, 0][1797, 3630, 1833, 0]Passed

SHA-256 / 1204028d94f4133a624427b699f3e784c996c6ce9e42a255f7c53b5b13fd2c1e

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
import calendar
N = 1
observations = []
def solve(x):
    s = datetime.date(*x['start'])
    e = datetime.date(*x['end'])
    c = datetime.date(*x['change'])
    total = (e - s).days
    remaining = (e - c).days
    def pr(p):
        return (p * remaining * 2 + total) // (2 * total)
    credit = pr(x['old'])
    charge = pr(x['new'])
    net = charge - credit
    return [credit, charge, max(0, net), max(0, -net)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'old': 12063, 'new': 1999, 'start': [2024, 10, 16], 'end': [2024, 11, 14], 'change': [2024, 11, 2]}, [4992, 827, 0, 4165]), ('regression', {'old': 34933, 'new': 4900, 'start': [2024, 12, 28], 'end': [2025, 1, 28], 'change': [2025, 1, 22]}, [6761, 948, 0, 5813]), ('partial-repair probe', {'old': 38640, 'new': 36658, 'start': [2024, 12, 23], 'end': [2025, 1, 22], 'change': [2025, 1, 21]}, [1288, 1222, 0, 66]), ('partial-repair probe', {'old': 33928, 'new': 9900, 'start': [2025, 3, 24], 'end': [2025, 4, 24], 'change': [2025, 4, 16]}, [8756, 2555, 0, 6201]), ('normal control', {'old': 999, 'new': 1999, 'start': [2023, 10, 16], 'end': [2023, 11, 13], 'change': [2023, 11, 8]}, [178, 357, 179, 0]), ('normal control', {'old': 999, 'new': 1999, 'start': [2024, 9, 16], 'end': [2024, 12, 15], 'change': [2024, 12, 10]}, [56, 111, 55, 0]), ('normal control', {'old': 4900, 'new': 8489, 'start': [2024, 3, 22], 'end': [2024, 6, 20], 'change': [2024, 4, 18]}, [3430, 5942, 2512, 0]), ('normal control', {'old': 4900, 'new': 9900, 'start': [2024, 1, 10], 'end': [2024, 4, 9], 'change': [2024, 3, 7]}, [1797, 3630, 1833, 0])], [('regression', {'old': 34933, 'new': 4900, 'start': [2024, 12, 28], 'end': [2025, 1, 28], 'change': [2025, 1, 22]}, [6761, 948, 0, 5813]), ('regression', {'old': 38640, 'new': 36658, 'start': [2024, 12, 23], 'end': [2025, 1, 22], 'change': [2025, 1, 21]}, [1288, 1222, 0, 66]), ('partial-repair probe', {'old': 33928, 'new': 9900, 'start': [2025, 3, 24], 'end': [2025, 4, 24], 'change': [2025, 4, 16]}, [8756, 2555, 0, 6201]), ('partial-repair probe', {'old': 6384, 'new': 4900, 'start': [2023, 3, 23], 'end': [2023, 4, 23], 'change': [2023, 4, 13]}, [2059, 1581, 0, 478]), ('normal control', {'old': 4900, 'new': 9900, 'start': [2024, 6, 18], 'end': [2024, 7, 18], 'change': [2024, 6, 21]}, [4410, 8910, 4500, 0]), ('normal control', {'old': 999, 'new': 4900, 'start': [2025, 1, 22], 'end': [2025, 4, 22], 'change': [2025, 3, 8]}, [500, 2450, 1950, 0]), ('normal control', {'old': 7276, 'new': 43371, 'start': [2024, 5, 21], 'end': [2024, 8, 19], 'change': [2024, 6, 13]}, [5417, 32287, 26870, 0]), ('normal control', {'old': 4900, 'new': 14973, 'start': [2025, 4, 11], 'end': [2025, 5, 10], 'change': [2025, 4, 17]}, [3886, 11875, 7989, 0])], [('regression', {'old': 38640, 'new': 36658, 'start': [2024, 12, 23], 'end': [2025, 1, 22], 'change': [2025, 1, 21]}, [1288, 1222, 0, 66]), ('regression', {'old': 33928, 'new': 9900, 'start': [2025, 3, 24], 'end': [2025, 4, 24], 'change': [2025, 4, 16]}, [8756, 2555, 0, 6201]), ('partial-repair probe', {'old': 6384, 'new': 4900, 'start': [2023, 3, 23], 'end': [2023, 4, 23], 'change': [2023, 4, 13]}, [2059, 1581, 0, 478]), ('partial-repair probe', {'old': 23223, 'new': 4900, 'start': [2025, 2, 5], 'end': [2025, 3, 8], 'change': [2025, 2, 9]}, [20226, 4268, 0, 15958]), ('normal control', {'old': 4900, 'new': 9900, 'start': [2024, 11, 22], 'end': [2024, 12, 21], 'change': [2024, 12, 19]}, [338, 683, 345, 0]), ('normal control', {'old': 4900, 'new': 46132, 'start': [2024, 4, 13], 'end': [2024, 5, 12], 'change': [2024, 4, 30]}, [2028, 19089, 17061, 0]), ('normal control', {'old': 1999, 'new': 4900, 'start': [2023, 10, 12], 'end': [2024, 10, 11], 'change': [2024, 2, 28]}, [1238, 3034, 1796, 0]), ('normal control', {'old': 999, 'new': 9900, 'start': [2025, 5, 5], 'end': [2025, 6, 3], 'change': [2025, 5, 20]}, [482, 4779, 4297, 0])], [('regression', {'old': 33928, 'new': 9900, 'start': [2025, 3, 24], 'end': [2025, 4, 24], 'change': [2025, 4, 16]}, [8756, 2555, 0, 6201]), ('regression', {'old': 6384, 'new': 4900, 'start': [2023, 3, 23], 'end': [2023, 4, 23], 'change': [2023, 4, 13]}, [2059, 1581, 0, 478]), ('partial-repair probe', {'old': 4900, 'new': 1999, 'start': [2023, 7, 16], 'end': [2023, 10, 14], 'change': [2023, 9, 2]}, [2287, 933, 0, 1354]), ('partial-repair probe', {'old': 17701, 'new': 4900, 'start': [2024, 7, 1], 'end': [2024, 8, 1], 'change': [2024, 7, 6]}, [14846, 4110, 0, 10736]), ('normal control', {'old': 27165, 'new': 30410, 'start': [2023, 10, 29], 'end': [2024, 1, 27], 'change': [2023, 12, 28]}, [9055, 10137, 1082, 0]), ('normal control', {'old': 1999, 'new': 1999, 'start': [2024, 4, 24], 'end': [2024, 5, 25], 'change': [2024, 5, 23]}, [129, 129, 0, 0]), ('normal control', {'old': 1999, 'new': 9900, 'start': [2024, 7, 18], 'end': [2024, 8, 18], 'change': [2024, 8, 1]}, [1096, 5429, 4333, 0]), ('normal control', {'old': 1999, 'new': 1999, 'start': [2025, 5, 29], 'end': [2025, 6, 28], 'change': [2025, 6, 7]}, [1399, 1399, 0, 0])], [('regression', {'old': 6384, 'new': 4900, 'start': [2023, 3, 23], 'end': [2023, 4, 23], 'change': [2023, 4, 13]}, [2059, 1581, 0, 478]), ('regression', {'old': 23223, 'new': 4900, 'start': [2025, 2, 5], 'end': [2025, 3, 8], 'change': [2025, 2, 9]}, [20226, 4268, 0, 15958]), ('partial-repair probe', {'old': 41031, 'new': 1999, 'start': [2023, 6, 12], 'end': [2023, 7, 13], 'change': [2023, 7, 6]}, [9265, 451, 0, 8814]), ('partial-repair probe', {'old': 46901, 'new': 1999, 'start': [2023, 10, 17], 'end': [2023, 11, 15], 'change': [2023, 10, 28]}, [29111, 1241, 0, 27870]), ('normal control', {'old': 999, 'new': 4900, 'start': [2025, 5, 24], 'end': [2025, 6, 24], 'change': [2025, 5, 24]}, [999, 4900, 3901, 0]), ('normal control', {'old': 999, 'new': 9900, 'start': [2023, 10, 10], 'end': [2024, 10, 9], 'change': [2024, 4, 29]}, [446, 4421, 3975, 0]), ('normal control', {'old': 4900, 'new': 4900, 'start': [2024, 11, 23], 'end': [2025, 11, 24], 'change': [2025, 7, 22]}, [1673, 1673, 0, 0]), ('normal control', {'old': 1999, 'new': 1999, 'start': [2025, 3, 22], 'end': [2025, 6, 20], 'change': [2025, 5, 23]}, [622, 622, 0, 0])]]
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[4992, 827, 0, 4165][4992, 827, 0, 4165]Passed
regression 1[6761, 948, 0, 5813][6761, 948, 0, 5813]Passed
partial-repair probe 2[1288, 1222, 0, 66][1288, 1222, 0, 66]Passed
partial-repair probe 3[8756, 2555, 0, 6201][8756, 2555, 0, 6201]Passed
normal control 4[178, 357, 179, 0][178, 357, 179, 0]Passed
normal control 5[56, 111, 55, 0][56, 111, 55, 0]Passed
normal control 6[3430, 5942, 2512, 0][3430, 5942, 2512, 0]Passed
normal control 7[1797, 3630, 1833, 0][1797, 3630, 1833, 0]Passed

SHA-256 / eb07324a561068ca95af614c1b0669dd0fbd3a5cd299f8ef3a8f53616aa8bcfc

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

Case digest / 5be9d2db21eb6f119d92f1c802ba846f136d2e6e5da705682668a7b0df51c19d