FA-59661 / Subscription proration billing / Open access
Flat fee proration with metered usage: usage window end · case 01
Usage recorded on the cancellation day is billed after cancellation.
ROOT CAUSE
The usage window includes its exclusive end day.
VERIFIED REPAIR
Restore the contract rule at the usage window end step: use `x['from'] <= d < end`.
Unsuccessful approach: The attempt ignores the cancellation day and bills usage after cancellation.
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 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': 2900, 'period_days': 30, 'from': 8, 'cancel': 18, 'unit': 1, 'events': [[11, 351], [18, 145]]}, [967, 351]), ('regression', {'flat': 9900, 'period_days': 30, 'from': 7, 'cancel': None, 'unit': 5, 'events': [[19, 263], [24, 229], [30, 88]]}, [7590, 2460]), ('partial-repair probe', {'flat': 6972, 'period_days': 31, 'from': 29, 'cancel': 18, 'unit': 12, 'events': [[29, 170]]}, [0, 0]), ('partial-repair probe', {'flat': 9900, 'period_days': 31, 'from': 2, 'cancel': 7, 'unit': 12, 'events': [[8, 9], [1, 189]]}, [1597, 0]), ('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': 1, 'cancel': 9, 'unit': 12, 'events': [[9, 406], [6, 191], [15, 110], [21, 170]]}, [2640, 2292]), ('regression', {'flat': 9900, 'period_days': 31, 'from': 28, 'cancel': None, 'unit': 1, 'events': [[5, 255], [31, 301], [34, 232], [32, 348], [31, 344]]}, [958, 0]), ('partial-repair probe', {'flat': 6064, 'period_days': 30, 'from': 12, 'cancel': 13, 'unit': 12, 'events': [[26, 133], [7, 193]]}, [202, 0]), ('partial-repair probe', {'flat': 9900, 'period_days': 31, 'from': 20, 'cancel': 12, 'unit': 12, 'events': [[6, 157], [20, 102]]}, [0, 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': 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]), ('normal control', {'flat': 11245, 'period_days': 30, 'from': 4, 'cancel': None, 'unit': 5, 'events': [[15, 26], [32, 318], [2, 320], [5, 358]]}, [9746, 1920])], [('regression', {'flat': 2900, 'period_days': 30, 'from': 9, 'cancel': 11, 'unit': 5, 'events': [[17, 146], [29, 419], [11, 274], [28, 178]]}, [193, 0]), ('regression', {'flat': 2900, 'period_days': 30, 'from': 17, 'cancel': None, 'unit': 1, 'events': [[30, 166], [13, 369]]}, [1257, 0]), ('partial-repair probe', {'flat': 9900, 'period_days': 31, 'from': 4, 'cancel': 9, 'unit': 5, 'events': [[8, 43], [13, 477], [20, 415], [5, 98]]}, [1597, 705]), ('partial-repair probe', {'flat': 9900, 'period_days': 31, 'from': 3, 'cancel': 9, 'unit': 1, 'events': [[0, 290], [26, 36], [2, 484], [34, 261], [29, 328]]}, [1916, 0]), ('normal control', {'flat': 2900, 'period_days': 30, 'from': 26, 'cancel': None, 'unit': 5, 'events': [[15, 372], [6, 377], [28, 0]]}, [387, 0]), ('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])], [('regression', {'flat': 17089, 'period_days': 30, 'from': 29, 'cancel': 29, 'unit': 1, 'events': [[29, 410], [0, 480]]}, [0, 0]), ('regression', {'flat': 9900, 'period_days': 31, 'from': 15, 'cancel': None, 'unit': 1, 'events': [[31, 257], [10, 174]]}, [5110, 0]), ('partial-repair probe', {'flat': 8642, 'period_days': 31, 'from': 18, 'cancel': 7, 'unit': 1, 'events': [[29, 202], [34, 89], [6, 171], [22, 438]]}, [0, 0]), ('partial-repair probe', {'flat': 19412, 'period_days': 31, 'from': 20, 'cancel': 5, 'unit': 1, 'events': [[24, 31], [33, 70], [10, 181], [33, 416], [15, 11]]}, [0, 0]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 23, 'cancel': None, 'unit': 1, 'events': [[6, 153]]}, [2555, 0]), ('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': 7417, 'period_days': 30, 'from': 29, 'cancel': None, 'unit': 12, 'events': [[3, 477], [17, 75]]}, [247, 0])], [('regression', {'flat': 2900, 'period_days': 30, 'from': 8, 'cancel': 18, 'unit': 1, 'events': [[11, 351], [18, 145]]}, [967, 351]), ('regression', {'flat': 9900, 'period_days': 30, 'from': 26, 'cancel': None, 'unit': 12, 'events': [[2, 455], [30, 158], [31, 273], [22, 144], [5, 161]]}, [1320, 0]), ('partial-repair probe', {'flat': 11559, 'period_days': 31, 'from': 6, 'cancel': 11, 'unit': 12, 'events': [[8, 414], [26, 37], [7, 254], [0, 293], [32, 417]]}, [1864, 8016]), ('partial-repair probe', {'flat': 8700, 'period_days': 31, 'from': 23, 'cancel': 15, 'unit': 12, 'events': [[30, 500], [2, 445]]}, [0, 0]), ('normal control', {'flat': 2900, 'period_days': 31, 'from': 14, 'cancel': None, 'unit': 12, 'events': [[17, 142], [9, 377]]}, [1590, 1704]), ('normal control', {'flat': 5810, 'period_days': 31, 'from': 30, 'cancel': None, 'unit': 12, 'events': [[34, 461], [26, 338], [10, 165], [21, 409], [28, 482]]}, [187, 0]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 6, 'cancel': None, 'unit': 1, 'events': [[16, 479], [10, 21], [5, 38], [25, 297], [6, 311]]}, [7984, 1108]), ('normal control', {'flat': 9900, 'period_days': 30, 'from': 13, 'cancel': None, 'unit': 5, 'events': [[10, 56]]}, [5610, 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 | [967, 496] | [967, 351] | Failed |
| regression 1 | [7590, 2900] | [7590, 2460] | Failed |
| partial-repair probe 2 | [0, 0] | [0, 0] | Passed |
| partial-repair probe 3 | [1597, 0] | [1597, 0] | 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 / 797e9f7ba8b009b9ea2be15237c45bc65cad5d0ae358f14985f40fe0c7137448
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'])
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 < x['period_days']) * x['unit']
return [flat, usage]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'flat': 2900, 'period_days': 30, 'from': 8, 'cancel': 18, 'unit': 1, 'events': [[11, 351], [18, 145]]}, [967, 351]), ('regression', {'flat': 9900, 'period_days': 30, 'from': 7, 'cancel': None, 'unit': 5, 'events': [[19, 263], [24, 229], [30, 88]]}, [7590, 2460]), ('partial-repair probe', {'flat': 6972, 'period_days': 31, 'from': 29, 'cancel': 18, 'unit': 12, 'events': [[29, 170]]}, [0, 0]), ('partial-repair probe', {'flat': 9900, 'period_days': 31, 'from': 2, 'cancel': 7, 'unit': 12, 'events': [[8, 9], [1, 189]]}, [1597, 0]), ('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': 1, 'cancel': 9, 'unit': 12, 'events': [[9, 406], [6, 191], [15, 110], [21, 170]]}, [2640, 2292]), ('regression', {'flat': 9900, 'period_days': 31, 'from': 28, 'cancel': None, 'unit': 1, 'events': [[5, 255], [31, 301], [34, 232], [32, 348], [31, 344]]}, [958, 0]), ('partial-repair probe', {'flat': 6064, 'period_days': 30, 'from': 12, 'cancel': 13, 'unit': 12, 'events': [[26, 133], [7, 193]]}, [202, 0]), ('partial-repair probe', {'flat': 9900, 'period_days': 31, 'from': 20, 'cancel': 12, 'unit': 12, 'events': [[6, 157], [20, 102]]}, [0, 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': 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]), ('normal control', {'flat': 11245, 'period_days': 30, 'from': 4, 'cancel': None, 'unit': 5, 'events': [[15, 26], [32, 318], [2, 320], [5, 358]]}, [9746, 1920])], [('regression', {'flat': 2900, 'period_days': 30, 'from': 9, 'cancel': 11, 'unit': 5, 'events': [[17, 146], [29, 419], [11, 274], [28, 178]]}, [193, 0]), ('regression', {'flat': 2900, 'period_days': 30, 'from': 17, 'cancel': None, 'unit': 1, 'events': [[30, 166], [13, 369]]}, [1257, 0]), ('partial-repair probe', {'flat': 9900, 'period_days': 31, 'from': 4, 'cancel': 9, 'unit': 5, 'events': [[8, 43], [13, 477], [20, 415], [5, 98]]}, [1597, 705]), ('partial-repair probe', {'flat': 9900, 'period_days': 31, 'from': 3, 'cancel': 9, 'unit': 1, 'events': [[0, 290], [26, 36], [2, 484], [34, 261], [29, 328]]}, [1916, 0]), ('normal control', {'flat': 2900, 'period_days': 30, 'from': 26, 'cancel': None, 'unit': 5, 'events': [[15, 372], [6, 377], [28, 0]]}, [387, 0]), ('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])], [('regression', {'flat': 17089, 'period_days': 30, 'from': 29, 'cancel': 29, 'unit': 1, 'events': [[29, 410], [0, 480]]}, [0, 0]), ('regression', {'flat': 9900, 'period_days': 31, 'from': 15, 'cancel': None, 'unit': 1, 'events': [[31, 257], [10, 174]]}, [5110, 0]), ('partial-repair probe', {'flat': 8642, 'period_days': 31, 'from': 18, 'cancel': 7, 'unit': 1, 'events': [[29, 202], [34, 89], [6, 171], [22, 438]]}, [0, 0]), ('partial-repair probe', {'flat': 19412, 'period_days': 31, 'from': 20, 'cancel': 5, 'unit': 1, 'events': [[24, 31], [33, 70], [10, 181], [33, 416], [15, 11]]}, [0, 0]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 23, 'cancel': None, 'unit': 1, 'events': [[6, 153]]}, [2555, 0]), ('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': 7417, 'period_days': 30, 'from': 29, 'cancel': None, 'unit': 12, 'events': [[3, 477], [17, 75]]}, [247, 0])], [('regression', {'flat': 2900, 'period_days': 30, 'from': 8, 'cancel': 18, 'unit': 1, 'events': [[11, 351], [18, 145]]}, [967, 351]), ('regression', {'flat': 9900, 'period_days': 30, 'from': 26, 'cancel': None, 'unit': 12, 'events': [[2, 455], [30, 158], [31, 273], [22, 144], [5, 161]]}, [1320, 0]), ('partial-repair probe', {'flat': 11559, 'period_days': 31, 'from': 6, 'cancel': 11, 'unit': 12, 'events': [[8, 414], [26, 37], [7, 254], [0, 293], [32, 417]]}, [1864, 8016]), ('partial-repair probe', {'flat': 8700, 'period_days': 31, 'from': 23, 'cancel': 15, 'unit': 12, 'events': [[30, 500], [2, 445]]}, [0, 0]), ('normal control', {'flat': 2900, 'period_days': 31, 'from': 14, 'cancel': None, 'unit': 12, 'events': [[17, 142], [9, 377]]}, [1590, 1704]), ('normal control', {'flat': 5810, 'period_days': 31, 'from': 30, 'cancel': None, 'unit': 12, 'events': [[34, 461], [26, 338], [10, 165], [21, 409], [28, 482]]}, [187, 0]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 6, 'cancel': None, 'unit': 1, 'events': [[16, 479], [10, 21], [5, 38], [25, 297], [6, 311]]}, [7984, 1108]), ('normal control', {'flat': 9900, 'period_days': 30, 'from': 13, 'cancel': None, 'unit': 5, 'events': [[10, 56]]}, [5610, 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 | [967, 496] | [967, 351] | Failed |
| regression 1 | [7590, 2460] | [7590, 2460] | Passed |
| partial-repair probe 2 | [0, 2040] | [0, 0] | Failed |
| partial-repair probe 3 | [1597, 108] | [1597, 0] | 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 / b4de58f12db15b8b832b5fc3e899c28113c642cfa7f5d46d31fe8aeeeb888642
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': 2900, 'period_days': 30, 'from': 8, 'cancel': 18, 'unit': 1, 'events': [[11, 351], [18, 145]]}, [967, 351]), ('regression', {'flat': 9900, 'period_days': 30, 'from': 7, 'cancel': None, 'unit': 5, 'events': [[19, 263], [24, 229], [30, 88]]}, [7590, 2460]), ('partial-repair probe', {'flat': 6972, 'period_days': 31, 'from': 29, 'cancel': 18, 'unit': 12, 'events': [[29, 170]]}, [0, 0]), ('partial-repair probe', {'flat': 9900, 'period_days': 31, 'from': 2, 'cancel': 7, 'unit': 12, 'events': [[8, 9], [1, 189]]}, [1597, 0]), ('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': 1, 'cancel': 9, 'unit': 12, 'events': [[9, 406], [6, 191], [15, 110], [21, 170]]}, [2640, 2292]), ('regression', {'flat': 9900, 'period_days': 31, 'from': 28, 'cancel': None, 'unit': 1, 'events': [[5, 255], [31, 301], [34, 232], [32, 348], [31, 344]]}, [958, 0]), ('partial-repair probe', {'flat': 6064, 'period_days': 30, 'from': 12, 'cancel': 13, 'unit': 12, 'events': [[26, 133], [7, 193]]}, [202, 0]), ('partial-repair probe', {'flat': 9900, 'period_days': 31, 'from': 20, 'cancel': 12, 'unit': 12, 'events': [[6, 157], [20, 102]]}, [0, 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': 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]), ('normal control', {'flat': 11245, 'period_days': 30, 'from': 4, 'cancel': None, 'unit': 5, 'events': [[15, 26], [32, 318], [2, 320], [5, 358]]}, [9746, 1920])], [('regression', {'flat': 2900, 'period_days': 30, 'from': 9, 'cancel': 11, 'unit': 5, 'events': [[17, 146], [29, 419], [11, 274], [28, 178]]}, [193, 0]), ('regression', {'flat': 2900, 'period_days': 30, 'from': 17, 'cancel': None, 'unit': 1, 'events': [[30, 166], [13, 369]]}, [1257, 0]), ('partial-repair probe', {'flat': 9900, 'period_days': 31, 'from': 4, 'cancel': 9, 'unit': 5, 'events': [[8, 43], [13, 477], [20, 415], [5, 98]]}, [1597, 705]), ('partial-repair probe', {'flat': 9900, 'period_days': 31, 'from': 3, 'cancel': 9, 'unit': 1, 'events': [[0, 290], [26, 36], [2, 484], [34, 261], [29, 328]]}, [1916, 0]), ('normal control', {'flat': 2900, 'period_days': 30, 'from': 26, 'cancel': None, 'unit': 5, 'events': [[15, 372], [6, 377], [28, 0]]}, [387, 0]), ('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])], [('regression', {'flat': 17089, 'period_days': 30, 'from': 29, 'cancel': 29, 'unit': 1, 'events': [[29, 410], [0, 480]]}, [0, 0]), ('regression', {'flat': 9900, 'period_days': 31, 'from': 15, 'cancel': None, 'unit': 1, 'events': [[31, 257], [10, 174]]}, [5110, 0]), ('partial-repair probe', {'flat': 8642, 'period_days': 31, 'from': 18, 'cancel': 7, 'unit': 1, 'events': [[29, 202], [34, 89], [6, 171], [22, 438]]}, [0, 0]), ('partial-repair probe', {'flat': 19412, 'period_days': 31, 'from': 20, 'cancel': 5, 'unit': 1, 'events': [[24, 31], [33, 70], [10, 181], [33, 416], [15, 11]]}, [0, 0]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 23, 'cancel': None, 'unit': 1, 'events': [[6, 153]]}, [2555, 0]), ('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': 7417, 'period_days': 30, 'from': 29, 'cancel': None, 'unit': 12, 'events': [[3, 477], [17, 75]]}, [247, 0])], [('regression', {'flat': 2900, 'period_days': 30, 'from': 8, 'cancel': 18, 'unit': 1, 'events': [[11, 351], [18, 145]]}, [967, 351]), ('regression', {'flat': 9900, 'period_days': 30, 'from': 26, 'cancel': None, 'unit': 12, 'events': [[2, 455], [30, 158], [31, 273], [22, 144], [5, 161]]}, [1320, 0]), ('partial-repair probe', {'flat': 11559, 'period_days': 31, 'from': 6, 'cancel': 11, 'unit': 12, 'events': [[8, 414], [26, 37], [7, 254], [0, 293], [32, 417]]}, [1864, 8016]), ('partial-repair probe', {'flat': 8700, 'period_days': 31, 'from': 23, 'cancel': 15, 'unit': 12, 'events': [[30, 500], [2, 445]]}, [0, 0]), ('normal control', {'flat': 2900, 'period_days': 31, 'from': 14, 'cancel': None, 'unit': 12, 'events': [[17, 142], [9, 377]]}, [1590, 1704]), ('normal control', {'flat': 5810, 'period_days': 31, 'from': 30, 'cancel': None, 'unit': 12, 'events': [[34, 461], [26, 338], [10, 165], [21, 409], [28, 482]]}, [187, 0]), ('normal control', {'flat': 9900, 'period_days': 31, 'from': 6, 'cancel': None, 'unit': 1, 'events': [[16, 479], [10, 21], [5, 38], [25, 297], [6, 311]]}, [7984, 1108]), ('normal control', {'flat': 9900, 'period_days': 30, 'from': 13, 'cancel': None, 'unit': 5, 'events': [[10, 56]]}, [5610, 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 | [967, 351] | [967, 351] | Passed |
| regression 1 | [7590, 2460] | [7590, 2460] | Passed |
| partial-repair probe 2 | [0, 0] | [0, 0] | Passed |
| partial-repair probe 3 | [1597, 0] | [1597, 0] | 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 / 00283c80427591e5767fd868930e956b0941f0a9dea40b37b65c491fb80c929b
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.356804+00:00.
Case digest / 77e87d51bb6eacd7686c5c8498c9cbe75f60ad3dfabcab992d07ca96a0c2fd57