FA-59666 / Subscription proration billing / Open access
Flat fee proration with metered usage: cancel beyond period · case 01
Cancellations scheduled after period end over-charge the flat fee beyond one period.
ROOT CAUSE
A cancellation day past the period end is not capped at the period length.
VERIFIED REPAIR
Restore the contract rule at the cancel beyond period step: use `min(x['cancel'], x['period_days'])`.
Unsuccessful approach: The attempt caps one day short, dropping the last day of the period.
Case contract
Input {flat, period_days, from, cancel|None, unit, events: [[day, qty]]}. Active window is [from, end) with end = min(cancel, period_days) or period_days. The flat fee is prorated by active days half-up; usage is not prorated: every event inside the window is billed qty*unit. Return [flat_charge, usage_charge].
Why this case matters
Only the recurring fee is prorated; metered usage is billed exactly for the active window.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
end = x['period_days'] if x['cancel'] is None else x['cancel']
active = max(0, end - x['from'])
flat = (x['flat'] * active * 2 + x['period_days']) // (2 * x['period_days'])
usage = sum(q for d, q in x['events'] if x['from'] <= d < end) * x['unit']
return [flat, usage]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'flat': 12750, 'period_days': 31, 'from': 9, 'cancel': 35, 'unit': 12, 'events': [[11, 0], [5, 260]]}, [9048, 0]), ('regression', {'flat': 9900, 'period_days': 30, 'from': 17, 'cancel': 31, 'unit': 5, 'events': [[29, 3], [33, 458], [32, 149]]}, [4290, 15]), ('partial-repair probe', {'flat': 14957, 'period_days': 31, 'from': 19, 'cancel': 31, 'unit': 1, 'events': [[30, 430], [15, 227]]}, [5790, 430]), ('partial-repair probe', {'flat': 18610, 'period_days': 31, 'from': 23, 'cancel': 32, 'unit': 1, 'events': [[28, 208], [5, 81], [3, 463], [1, 258]]}, [4803, 208]), ('normal control', {'flat': 2900, 'period_days': 30, 'from': 15, 'cancel': None, 'unit': 5, 'events': [[26, 260], [12, 213]]}, [1450, 1300]), ('normal control', {'flat': 8044, 'period_days': 31, 'from': 14, 'cancel': None, 'unit': 5, 'events': []}, [4411, 0]), ('normal control', {'flat': 2900, 'period_days': 31, 'from': 23, 'cancel': None, 'unit': 12, 'events': [[13, 491]]}, [748, 0]), ('normal control', {'flat': 12170, 'period_days': 30, 'from': 3, 'cancel': None, 'unit': 12, 'events': [[23, 155], [28, 348], [21, 236]]}, [10953, 8868])], [('regression', {'flat': 9900, 'period_days': 30, 'from': 17, 'cancel': 31, 'unit': 5, 'events': [[29, 3], [33, 458], [32, 149]]}, [4290, 15]), ('regression', {'flat': 18610, 'period_days': 31, 'from': 23, 'cancel': 32, 'unit': 1, 'events': [[28, 208], [5, 81], [3, 463], [1, 258]]}, [4803, 208]), ('partial-repair probe', {'flat': 2900, 'period_days': 31, 'from': 18, 'cancel': 35, 'unit': 1, 'events': [[6, 14], [2, 29], [14, 174], [8, 175], [1, 162]]}, [1216, 0]), ('partial-repair probe', {'flat': 4163, 'period_days': 31, 'from': 10, 'cancel': 34, 'unit': 1, 'events': []}, [2820, 0]), ('normal control', {'flat': 7431, 'period_days': 31, 'from': 30, 'cancel': None, 'unit': 12, 'events': [[6, 380], [30, 5], [32, 257], [4, 247]]}, [240, 60]), ('normal control', {'flat': 6972, 'period_days': 31, 'from': 29, 'cancel': 18, 'unit': 12, 'events': [[29, 170]]}, [0, 0]), ('normal control', {'flat': 2900, 'period_days': 31, 'from': 7, 'cancel': None, 'unit': 5, 'events': [[19, 421], [6, 32], [33, 481]]}, [2245, 2105]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 22, 'cancel': None, 'unit': 12, 'events': [[18, 186], [30, 275], [20, 173], [26, 168]]}, [2874, 5316])], [('regression', {'flat': 18610, 'period_days': 31, 'from': 23, 'cancel': 32, 'unit': 1, 'events': [[28, 208], [5, 81], [3, 463], [1, 258]]}, [4803, 208]), ('regression', {'flat': 2900, 'period_days': 31, 'from': 18, 'cancel': 35, 'unit': 1, 'events': [[6, 14], [2, 29], [14, 174], [8, 175], [1, 162]]}, [1216, 0]), ('partial-repair probe', {'flat': 4163, 'period_days': 31, 'from': 10, 'cancel': 34, 'unit': 1, 'events': []}, [2820, 0]), ('partial-repair probe', {'flat': 2900, 'period_days': 31, 'from': 20, 'cancel': 31, 'unit': 5, 'events': []}, [1029, 0]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 2, 'cancel': 7, 'unit': 12, 'events': [[8, 9], [1, 189]]}, [1597, 0]), ('normal control', {'flat': 11245, 'period_days': 30, 'from': 4, 'cancel': None, 'unit': 5, 'events': [[15, 26], [32, 318], [2, 320], [5, 358]]}, [9746, 1920]), ('normal control', {'flat': 6064, 'period_days': 30, 'from': 12, 'cancel': 13, 'unit': 12, 'events': [[26, 133], [7, 193]]}, [202, 0]), ('normal control', {'flat': 2900, 'period_days': 30, 'from': 26, 'cancel': None, 'unit': 5, 'events': [[15, 372], [6, 377], [28, 0]]}, [387, 0])], [('regression', {'flat': 2900, 'period_days': 31, 'from': 18, 'cancel': 35, 'unit': 1, 'events': [[6, 14], [2, 29], [14, 174], [8, 175], [1, 162]]}, [1216, 0]), ('regression', {'flat': 4163, 'period_days': 31, 'from': 10, 'cancel': 34, 'unit': 1, 'events': []}, [2820, 0]), ('partial-repair probe', {'flat': 2900, 'period_days': 31, 'from': 20, 'cancel': 31, 'unit': 5, 'events': []}, [1029, 0]), ('partial-repair probe', {'flat': 14326, 'period_days': 30, 'from': 22, 'cancel': 33, 'unit': 5, 'events': [[20, 248], [10, 96], [30, 105], [28, 63], [23, 418]]}, [3820, 2405]), ('normal control', {'flat': 2900, 'period_days': 31, 'from': 0, 'cancel': None, 'unit': 5, 'events': [[10, 43], [0, 320]]}, [2900, 1815]), ('normal control', {'flat': 9900, 'period_days': 30, 'from': 15, 'cancel': None, 'unit': 12, 'events': [[15, 259], [0, 271]]}, [4950, 3108]), ('normal control', {'flat': 2900, 'period_days': 30, 'from': 10, 'cancel': None, 'unit': 5, 'events': []}, [1933, 0]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 23, 'cancel': None, 'unit': 1, 'events': [[6, 153]]}, [2555, 0])], [('regression', {'flat': 4163, 'period_days': 31, 'from': 10, 'cancel': 34, 'unit': 1, 'events': []}, [2820, 0]), ('regression', {'flat': 14326, 'period_days': 30, 'from': 22, 'cancel': 33, 'unit': 5, 'events': [[20, 248], [10, 96], [30, 105], [28, 63], [23, 418]]}, [3820, 2405]), ('partial-repair probe', {'flat': 2900, 'period_days': 31, 'from': 30, 'cancel': 33, 'unit': 5, 'events': [[31, 73], [20, 385], [19, 458], [28, 51], [22, 381]]}, [94, 0]), ('partial-repair probe', {'flat': 9900, 'period_days': 30, 'from': 16, 'cancel': 33, 'unit': 5, 'events': [[15, 49], [18, 384], [24, 326], [31, 197]]}, [4620, 3550]), ('normal control', {'flat': 4788, 'period_days': 31, 'from': 25, 'cancel': None, 'unit': 1, 'events': [[15, 413]]}, [927, 0]), ('normal control', {'flat': 2900, 'period_days': 31, 'from': 2, 'cancel': None, 'unit': 1, 'events': [[1, 283], [5, 461], [7, 359], [22, 264], [5, 31]]}, [2713, 1115]), ('normal control', {'flat': 9900, 'period_days': 30, 'from': 7, 'cancel': None, 'unit': 5, 'events': [[19, 263], [24, 229], [30, 88]]}, [7590, 2460]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 20, 'cancel': 12, 'unit': 12, 'events': [[6, 157], [20, 102]]}, [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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression 0 | [10694, 0] | [9048, 0] | Failed |
| regression 1 | [4620, 15] | [4290, 15] | Failed |
| partial-repair probe 2 | [5790, 430] | [5790, 430] | Passed |
| partial-repair probe 3 | [5403, 208] | [4803, 208] | Failed |
| normal control 4 | [1450, 1300] | [1450, 1300] | Passed |
| normal control 5 | [4411, 0] | [4411, 0] | Passed |
| normal control 6 | [748, 0] | [748, 0] | Passed |
| normal control 7 | [10953, 8868] | [10953, 8868] | Passed |
SHA-256 / d674f85c8f95534fbec2a2a0f429fde3675e81606b884ed5ed09efe6888d1a67
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
end = x['period_days'] if x['cancel'] is None else min(x['cancel'], x['period_days'] - 1)
active = max(0, end - x['from'])
flat = (x['flat'] * active * 2 + x['period_days']) // (2 * x['period_days'])
usage = sum(q for d, q in x['events'] if x['from'] <= d < end) * x['unit']
return [flat, usage]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'flat': 12750, 'period_days': 31, 'from': 9, 'cancel': 35, 'unit': 12, 'events': [[11, 0], [5, 260]]}, [9048, 0]), ('regression', {'flat': 9900, 'period_days': 30, 'from': 17, 'cancel': 31, 'unit': 5, 'events': [[29, 3], [33, 458], [32, 149]]}, [4290, 15]), ('partial-repair probe', {'flat': 14957, 'period_days': 31, 'from': 19, 'cancel': 31, 'unit': 1, 'events': [[30, 430], [15, 227]]}, [5790, 430]), ('partial-repair probe', {'flat': 18610, 'period_days': 31, 'from': 23, 'cancel': 32, 'unit': 1, 'events': [[28, 208], [5, 81], [3, 463], [1, 258]]}, [4803, 208]), ('normal control', {'flat': 2900, 'period_days': 30, 'from': 15, 'cancel': None, 'unit': 5, 'events': [[26, 260], [12, 213]]}, [1450, 1300]), ('normal control', {'flat': 8044, 'period_days': 31, 'from': 14, 'cancel': None, 'unit': 5, 'events': []}, [4411, 0]), ('normal control', {'flat': 2900, 'period_days': 31, 'from': 23, 'cancel': None, 'unit': 12, 'events': [[13, 491]]}, [748, 0]), ('normal control', {'flat': 12170, 'period_days': 30, 'from': 3, 'cancel': None, 'unit': 12, 'events': [[23, 155], [28, 348], [21, 236]]}, [10953, 8868])], [('regression', {'flat': 9900, 'period_days': 30, 'from': 17, 'cancel': 31, 'unit': 5, 'events': [[29, 3], [33, 458], [32, 149]]}, [4290, 15]), ('regression', {'flat': 18610, 'period_days': 31, 'from': 23, 'cancel': 32, 'unit': 1, 'events': [[28, 208], [5, 81], [3, 463], [1, 258]]}, [4803, 208]), ('partial-repair probe', {'flat': 2900, 'period_days': 31, 'from': 18, 'cancel': 35, 'unit': 1, 'events': [[6, 14], [2, 29], [14, 174], [8, 175], [1, 162]]}, [1216, 0]), ('partial-repair probe', {'flat': 4163, 'period_days': 31, 'from': 10, 'cancel': 34, 'unit': 1, 'events': []}, [2820, 0]), ('normal control', {'flat': 7431, 'period_days': 31, 'from': 30, 'cancel': None, 'unit': 12, 'events': [[6, 380], [30, 5], [32, 257], [4, 247]]}, [240, 60]), ('normal control', {'flat': 6972, 'period_days': 31, 'from': 29, 'cancel': 18, 'unit': 12, 'events': [[29, 170]]}, [0, 0]), ('normal control', {'flat': 2900, 'period_days': 31, 'from': 7, 'cancel': None, 'unit': 5, 'events': [[19, 421], [6, 32], [33, 481]]}, [2245, 2105]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 22, 'cancel': None, 'unit': 12, 'events': [[18, 186], [30, 275], [20, 173], [26, 168]]}, [2874, 5316])], [('regression', {'flat': 18610, 'period_days': 31, 'from': 23, 'cancel': 32, 'unit': 1, 'events': [[28, 208], [5, 81], [3, 463], [1, 258]]}, [4803, 208]), ('regression', {'flat': 2900, 'period_days': 31, 'from': 18, 'cancel': 35, 'unit': 1, 'events': [[6, 14], [2, 29], [14, 174], [8, 175], [1, 162]]}, [1216, 0]), ('partial-repair probe', {'flat': 4163, 'period_days': 31, 'from': 10, 'cancel': 34, 'unit': 1, 'events': []}, [2820, 0]), ('partial-repair probe', {'flat': 2900, 'period_days': 31, 'from': 20, 'cancel': 31, 'unit': 5, 'events': []}, [1029, 0]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 2, 'cancel': 7, 'unit': 12, 'events': [[8, 9], [1, 189]]}, [1597, 0]), ('normal control', {'flat': 11245, 'period_days': 30, 'from': 4, 'cancel': None, 'unit': 5, 'events': [[15, 26], [32, 318], [2, 320], [5, 358]]}, [9746, 1920]), ('normal control', {'flat': 6064, 'period_days': 30, 'from': 12, 'cancel': 13, 'unit': 12, 'events': [[26, 133], [7, 193]]}, [202, 0]), ('normal control', {'flat': 2900, 'period_days': 30, 'from': 26, 'cancel': None, 'unit': 5, 'events': [[15, 372], [6, 377], [28, 0]]}, [387, 0])], [('regression', {'flat': 2900, 'period_days': 31, 'from': 18, 'cancel': 35, 'unit': 1, 'events': [[6, 14], [2, 29], [14, 174], [8, 175], [1, 162]]}, [1216, 0]), ('regression', {'flat': 4163, 'period_days': 31, 'from': 10, 'cancel': 34, 'unit': 1, 'events': []}, [2820, 0]), ('partial-repair probe', {'flat': 2900, 'period_days': 31, 'from': 20, 'cancel': 31, 'unit': 5, 'events': []}, [1029, 0]), ('partial-repair probe', {'flat': 14326, 'period_days': 30, 'from': 22, 'cancel': 33, 'unit': 5, 'events': [[20, 248], [10, 96], [30, 105], [28, 63], [23, 418]]}, [3820, 2405]), ('normal control', {'flat': 2900, 'period_days': 31, 'from': 0, 'cancel': None, 'unit': 5, 'events': [[10, 43], [0, 320]]}, [2900, 1815]), ('normal control', {'flat': 9900, 'period_days': 30, 'from': 15, 'cancel': None, 'unit': 12, 'events': [[15, 259], [0, 271]]}, [4950, 3108]), ('normal control', {'flat': 2900, 'period_days': 30, 'from': 10, 'cancel': None, 'unit': 5, 'events': []}, [1933, 0]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 23, 'cancel': None, 'unit': 1, 'events': [[6, 153]]}, [2555, 0])], [('regression', {'flat': 4163, 'period_days': 31, 'from': 10, 'cancel': 34, 'unit': 1, 'events': []}, [2820, 0]), ('regression', {'flat': 14326, 'period_days': 30, 'from': 22, 'cancel': 33, 'unit': 5, 'events': [[20, 248], [10, 96], [30, 105], [28, 63], [23, 418]]}, [3820, 2405]), ('partial-repair probe', {'flat': 2900, 'period_days': 31, 'from': 30, 'cancel': 33, 'unit': 5, 'events': [[31, 73], [20, 385], [19, 458], [28, 51], [22, 381]]}, [94, 0]), ('partial-repair probe', {'flat': 9900, 'period_days': 30, 'from': 16, 'cancel': 33, 'unit': 5, 'events': [[15, 49], [18, 384], [24, 326], [31, 197]]}, [4620, 3550]), ('normal control', {'flat': 4788, 'period_days': 31, 'from': 25, 'cancel': None, 'unit': 1, 'events': [[15, 413]]}, [927, 0]), ('normal control', {'flat': 2900, 'period_days': 31, 'from': 2, 'cancel': None, 'unit': 1, 'events': [[1, 283], [5, 461], [7, 359], [22, 264], [5, 31]]}, [2713, 1115]), ('normal control', {'flat': 9900, 'period_days': 30, 'from': 7, 'cancel': None, 'unit': 5, 'events': [[19, 263], [24, 229], [30, 88]]}, [7590, 2460]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 20, 'cancel': 12, 'unit': 12, 'events': [[6, 157], [20, 102]]}, [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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression 0 | [8637, 0] | [9048, 0] | Failed |
| regression 1 | [3960, 0] | [4290, 15] | Failed |
| partial-repair probe 2 | [5307, 0] | [5790, 430] | Failed |
| partial-repair probe 3 | [4202, 208] | [4803, 208] | Failed |
| normal control 4 | [1450, 1300] | [1450, 1300] | Passed |
| normal control 5 | [4411, 0] | [4411, 0] | Passed |
| normal control 6 | [748, 0] | [748, 0] | Passed |
| normal control 7 | [10953, 8868] | [10953, 8868] | Passed |
SHA-256 / 8e107ef204964d6a371cc1cdf19363f783817fb96129c785de6f28def5183ddf
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
end = x['period_days'] if x['cancel'] is None else min(x['cancel'], x['period_days'])
active = max(0, end - x['from'])
flat = (x['flat'] * active * 2 + x['period_days']) // (2 * x['period_days'])
usage = sum(q for d, q in x['events'] if x['from'] <= d < end) * x['unit']
return [flat, usage]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'flat': 12750, 'period_days': 31, 'from': 9, 'cancel': 35, 'unit': 12, 'events': [[11, 0], [5, 260]]}, [9048, 0]), ('regression', {'flat': 9900, 'period_days': 30, 'from': 17, 'cancel': 31, 'unit': 5, 'events': [[29, 3], [33, 458], [32, 149]]}, [4290, 15]), ('partial-repair probe', {'flat': 14957, 'period_days': 31, 'from': 19, 'cancel': 31, 'unit': 1, 'events': [[30, 430], [15, 227]]}, [5790, 430]), ('partial-repair probe', {'flat': 18610, 'period_days': 31, 'from': 23, 'cancel': 32, 'unit': 1, 'events': [[28, 208], [5, 81], [3, 463], [1, 258]]}, [4803, 208]), ('normal control', {'flat': 2900, 'period_days': 30, 'from': 15, 'cancel': None, 'unit': 5, 'events': [[26, 260], [12, 213]]}, [1450, 1300]), ('normal control', {'flat': 8044, 'period_days': 31, 'from': 14, 'cancel': None, 'unit': 5, 'events': []}, [4411, 0]), ('normal control', {'flat': 2900, 'period_days': 31, 'from': 23, 'cancel': None, 'unit': 12, 'events': [[13, 491]]}, [748, 0]), ('normal control', {'flat': 12170, 'period_days': 30, 'from': 3, 'cancel': None, 'unit': 12, 'events': [[23, 155], [28, 348], [21, 236]]}, [10953, 8868])], [('regression', {'flat': 9900, 'period_days': 30, 'from': 17, 'cancel': 31, 'unit': 5, 'events': [[29, 3], [33, 458], [32, 149]]}, [4290, 15]), ('regression', {'flat': 18610, 'period_days': 31, 'from': 23, 'cancel': 32, 'unit': 1, 'events': [[28, 208], [5, 81], [3, 463], [1, 258]]}, [4803, 208]), ('partial-repair probe', {'flat': 2900, 'period_days': 31, 'from': 18, 'cancel': 35, 'unit': 1, 'events': [[6, 14], [2, 29], [14, 174], [8, 175], [1, 162]]}, [1216, 0]), ('partial-repair probe', {'flat': 4163, 'period_days': 31, 'from': 10, 'cancel': 34, 'unit': 1, 'events': []}, [2820, 0]), ('normal control', {'flat': 7431, 'period_days': 31, 'from': 30, 'cancel': None, 'unit': 12, 'events': [[6, 380], [30, 5], [32, 257], [4, 247]]}, [240, 60]), ('normal control', {'flat': 6972, 'period_days': 31, 'from': 29, 'cancel': 18, 'unit': 12, 'events': [[29, 170]]}, [0, 0]), ('normal control', {'flat': 2900, 'period_days': 31, 'from': 7, 'cancel': None, 'unit': 5, 'events': [[19, 421], [6, 32], [33, 481]]}, [2245, 2105]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 22, 'cancel': None, 'unit': 12, 'events': [[18, 186], [30, 275], [20, 173], [26, 168]]}, [2874, 5316])], [('regression', {'flat': 18610, 'period_days': 31, 'from': 23, 'cancel': 32, 'unit': 1, 'events': [[28, 208], [5, 81], [3, 463], [1, 258]]}, [4803, 208]), ('regression', {'flat': 2900, 'period_days': 31, 'from': 18, 'cancel': 35, 'unit': 1, 'events': [[6, 14], [2, 29], [14, 174], [8, 175], [1, 162]]}, [1216, 0]), ('partial-repair probe', {'flat': 4163, 'period_days': 31, 'from': 10, 'cancel': 34, 'unit': 1, 'events': []}, [2820, 0]), ('partial-repair probe', {'flat': 2900, 'period_days': 31, 'from': 20, 'cancel': 31, 'unit': 5, 'events': []}, [1029, 0]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 2, 'cancel': 7, 'unit': 12, 'events': [[8, 9], [1, 189]]}, [1597, 0]), ('normal control', {'flat': 11245, 'period_days': 30, 'from': 4, 'cancel': None, 'unit': 5, 'events': [[15, 26], [32, 318], [2, 320], [5, 358]]}, [9746, 1920]), ('normal control', {'flat': 6064, 'period_days': 30, 'from': 12, 'cancel': 13, 'unit': 12, 'events': [[26, 133], [7, 193]]}, [202, 0]), ('normal control', {'flat': 2900, 'period_days': 30, 'from': 26, 'cancel': None, 'unit': 5, 'events': [[15, 372], [6, 377], [28, 0]]}, [387, 0])], [('regression', {'flat': 2900, 'period_days': 31, 'from': 18, 'cancel': 35, 'unit': 1, 'events': [[6, 14], [2, 29], [14, 174], [8, 175], [1, 162]]}, [1216, 0]), ('regression', {'flat': 4163, 'period_days': 31, 'from': 10, 'cancel': 34, 'unit': 1, 'events': []}, [2820, 0]), ('partial-repair probe', {'flat': 2900, 'period_days': 31, 'from': 20, 'cancel': 31, 'unit': 5, 'events': []}, [1029, 0]), ('partial-repair probe', {'flat': 14326, 'period_days': 30, 'from': 22, 'cancel': 33, 'unit': 5, 'events': [[20, 248], [10, 96], [30, 105], [28, 63], [23, 418]]}, [3820, 2405]), ('normal control', {'flat': 2900, 'period_days': 31, 'from': 0, 'cancel': None, 'unit': 5, 'events': [[10, 43], [0, 320]]}, [2900, 1815]), ('normal control', {'flat': 9900, 'period_days': 30, 'from': 15, 'cancel': None, 'unit': 12, 'events': [[15, 259], [0, 271]]}, [4950, 3108]), ('normal control', {'flat': 2900, 'period_days': 30, 'from': 10, 'cancel': None, 'unit': 5, 'events': []}, [1933, 0]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 23, 'cancel': None, 'unit': 1, 'events': [[6, 153]]}, [2555, 0])], [('regression', {'flat': 4163, 'period_days': 31, 'from': 10, 'cancel': 34, 'unit': 1, 'events': []}, [2820, 0]), ('regression', {'flat': 14326, 'period_days': 30, 'from': 22, 'cancel': 33, 'unit': 5, 'events': [[20, 248], [10, 96], [30, 105], [28, 63], [23, 418]]}, [3820, 2405]), ('partial-repair probe', {'flat': 2900, 'period_days': 31, 'from': 30, 'cancel': 33, 'unit': 5, 'events': [[31, 73], [20, 385], [19, 458], [28, 51], [22, 381]]}, [94, 0]), ('partial-repair probe', {'flat': 9900, 'period_days': 30, 'from': 16, 'cancel': 33, 'unit': 5, 'events': [[15, 49], [18, 384], [24, 326], [31, 197]]}, [4620, 3550]), ('normal control', {'flat': 4788, 'period_days': 31, 'from': 25, 'cancel': None, 'unit': 1, 'events': [[15, 413]]}, [927, 0]), ('normal control', {'flat': 2900, 'period_days': 31, 'from': 2, 'cancel': None, 'unit': 1, 'events': [[1, 283], [5, 461], [7, 359], [22, 264], [5, 31]]}, [2713, 1115]), ('normal control', {'flat': 9900, 'period_days': 30, 'from': 7, 'cancel': None, 'unit': 5, 'events': [[19, 263], [24, 229], [30, 88]]}, [7590, 2460]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 20, 'cancel': 12, 'unit': 12, 'events': [[6, 157], [20, 102]]}, [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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression 0 | [9048, 0] | [9048, 0] | Passed |
| regression 1 | [4290, 15] | [4290, 15] | Passed |
| partial-repair probe 2 | [5790, 430] | [5790, 430] | Passed |
| partial-repair probe 3 | [4803, 208] | [4803, 208] | Passed |
| normal control 4 | [1450, 1300] | [1450, 1300] | Passed |
| normal control 5 | [4411, 0] | [4411, 0] | Passed |
| normal control 6 | [748, 0] | [748, 0] | Passed |
| normal control 7 | [10953, 8868] | [10953, 8868] | Passed |
SHA-256 / bf67396463241cec9b583a3d33c61664df028e6735075572542313eb086ee7d0
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.476689+00:00.
Case digest / 781fb7f40bba3f006c27aff3eec6e2e4a3fbbb81812e03468f0990824543f501