FAILURE MAP
← Case archive

FA-59466 / Subscription proration billing / Open access

Paused days extending the billing period: empty interval filter · case 01

Pauses entirely outside the period shorten the subscription.

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

ROOT CAUSE

Inverted intervals left by clipping are kept, contributing negative days.

VERIFIED REPAIR

Restore the contract rule at the empty interval filter step: use `iv = [p for p in iv if p[0] < p[1]]`.

Unsuccessful approach: The attempt drops pauses ending before the start but keeps those starting after the end.

Case contract

Input {start, end (exclusive) day numbers, pauses: [[from, to)]}. Pause intervals are clipped to the period, empty ones dropped, then overlapping ones merged. The period end moves out by the number of distinct paused days. Return [new_end, paused_days].

Why this case matters

Pausing a subscription should extend paid service exactly by the paused time, no more and no less.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    s, e = x['start'], x['end']
    iv = sorted([max(a, s), min(b, e)] for a, b in x['pauses'])
    iv = [p for p in iv if p[0] != p[1]]
    merged = []
    for a, b in iv:
        if merged and a <= merged[-1][1]:
            merged[-1][1] = max(merged[-1][1], b)
        else:
            merged.append([a, b])
    paused = sum(b - a for a, b in merged)
    return [e + paused, paused]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'start': 86, 'end': 116, 'pauses': [[89, 104], [117, 132], [97, 102]]}, [131, 15]), ('regression', {'start': 34, 'end': 65, 'pauses': [[30, 33], [31, 34]]}, [65, 0]), ('partial-repair probe', {'start': 60, 'end': 88, 'pauses': [[92, 102], [57, 65], [85, 100]]}, [96, 8]), ('partial-repair probe', {'start': 94, 'end': 124, 'pauses': [[96, 99], [128, 143], [115, 130]]}, [136, 12]), ('normal control', {'start': 20, 'end': 48, 'pauses': [[28, 28], [16, 30], [23, 23]]}, [58, 10]), ('normal control', {'start': 15, 'end': 45, 'pauses': [[20, 34], [22, 25], [25, 35]]}, [60, 15]), ('normal control', {'start': 28, 'end': 56, 'pauses': [[45, 57], [44, 58], [33, 35], [48, 63]]}, [70, 14]), ('normal control', {'start': 12, 'end': 40, 'pauses': []}, [40, 0])], [('regression', {'start': 60, 'end': 88, 'pauses': [[92, 102], [57, 65], [85, 100]]}, [96, 8]), ('regression', {'start': 82, 'end': 112, 'pauses': [[76, 78], [84, 98], [94, 101], [102, 113]]}, [139, 27]), ('partial-repair probe', {'start': 94, 'end': 124, 'pauses': [[96, 99], [128, 143], [115, 130]]}, [136, 12]), ('partial-repair probe', {'start': 15, 'end': 45, 'pauses': [[45, 52], [44, 46], [45, 45], [49, 53]]}, [46, 1]), ('normal control', {'start': 73, 'end': 101, 'pauses': [[82, 97], [85, 93], [79, 80], [82, 85]]}, [117, 16]), ('normal control', {'start': 46, 'end': 76, 'pauses': [[72, 81]]}, [80, 4]), ('normal control', {'start': 92, 'end': 122, 'pauses': [[121, 121]]}, [122, 0]), ('normal control', {'start': 26, 'end': 56, 'pauses': []}, [56, 0])], [('regression', {'start': 94, 'end': 124, 'pauses': [[96, 99], [128, 143], [115, 130]]}, [136, 12]), ('regression', {'start': 100, 'end': 131, 'pauses': [[127, 128], [119, 120], [97, 98], [120, 128]]}, [140, 9]), ('partial-repair probe', {'start': 70, 'end': 100, 'pauses': [[79, 85], [103, 107]]}, [106, 6]), ('partial-repair probe', {'start': 30, 'end': 60, 'pauses': [[64, 71], [24, 29]]}, [60, 0]), ('normal control', {'start': 44, 'end': 72, 'pauses': [[58, 64], [45, 58], [59, 70], [41, 49]]}, [98, 26]), ('normal control', {'start': 84, 'end': 115, 'pauses': []}, [115, 0]), ('normal control', {'start': 86, 'end': 114, 'pauses': [[113, 121]]}, [115, 1]), ('normal control', {'start': 98, 'end': 126, 'pauses': [[121, 127], [123, 125]]}, [131, 5])], [('regression', {'start': 15, 'end': 45, 'pauses': [[45, 52], [44, 46], [45, 45], [49, 53]]}, [46, 1]), ('regression', {'start': 92, 'end': 120, 'pauses': [[82, 91]]}, [120, 0]), ('partial-repair probe', {'start': 61, 'end': 92, 'pauses': [[95, 108], [74, 88], [60, 67]]}, [112, 20]), ('partial-repair probe', {'start': 78, 'end': 106, 'pauses': [[109, 124]]}, [106, 0]), ('normal control', {'start': 96, 'end': 124, 'pauses': [[120, 128], [90, 105], [99, 105], [116, 125]]}, [141, 17]), ('normal control', {'start': 28, 'end': 56, 'pauses': [[35, 37], [21, 36]]}, [65, 9]), ('normal control', {'start': 14, 'end': 42, 'pauses': []}, [42, 0]), ('normal control', {'start': 56, 'end': 86, 'pauses': []}, [86, 0])], [('regression', {'start': 70, 'end': 100, 'pauses': [[79, 85], [103, 107]]}, [106, 6]), ('regression', {'start': 0, 'end': 31, 'pauses': [[31, 46], [24, 33], [-7, -3], [-8, 6]]}, [44, 13]), ('partial-repair probe', {'start': 74, 'end': 104, 'pauses': [[91, 106], [66, 68], [108, 111], [108, 119]]}, [117, 13]), ('partial-repair probe', {'start': 2, 'end': 33, 'pauses': [[34, 37], [22, 34], [-7, -2], [32, 33]]}, [44, 11]), ('normal control', {'start': 94, 'end': 125, 'pauses': [[103, 112], [94, 95], [111, 118], [87, 100]]}, [146, 21]), ('normal control', {'start': 19, 'end': 49, 'pauses': [[17, 21], [22, 37], [42, 42]]}, [66, 17]), ('normal control', {'start': 65, 'end': 93, 'pauses': []}, [93, 0]), ('normal control', {'start': 84, 'end': 114, 'pauses': [[96, 100], [88, 96], [80, 90]]}, [130, 16])]]
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[130, 14][131, 15]Failed
regression 1[64, -1][65, 0]Failed
partial-repair probe 2[92, 4][96, 8]Failed
partial-repair probe 3[132, 8][136, 12]Failed
normal control 4[58, 10][58, 10]Passed
normal control 5[60, 15][60, 15]Passed
normal control 6[70, 14][70, 14]Passed
normal control 7[40, 0][40, 0]Passed

SHA-256 / 1fe8307d0aab234ef8516b3e174b530d40e3393142699f7b7069600721394dee

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    s, e = x['start'], x['end']
    iv = sorted([max(a, s), min(b, e)] for a, b in x['pauses'])
    iv = [p for p in iv if p[1] > s]
    merged = []
    for a, b in iv:
        if merged and a <= merged[-1][1]:
            merged[-1][1] = max(merged[-1][1], b)
        else:
            merged.append([a, b])
    paused = sum(b - a for a, b in merged)
    return [e + paused, paused]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'start': 86, 'end': 116, 'pauses': [[89, 104], [117, 132], [97, 102]]}, [131, 15]), ('regression', {'start': 34, 'end': 65, 'pauses': [[30, 33], [31, 34]]}, [65, 0]), ('partial-repair probe', {'start': 60, 'end': 88, 'pauses': [[92, 102], [57, 65], [85, 100]]}, [96, 8]), ('partial-repair probe', {'start': 94, 'end': 124, 'pauses': [[96, 99], [128, 143], [115, 130]]}, [136, 12]), ('normal control', {'start': 20, 'end': 48, 'pauses': [[28, 28], [16, 30], [23, 23]]}, [58, 10]), ('normal control', {'start': 15, 'end': 45, 'pauses': [[20, 34], [22, 25], [25, 35]]}, [60, 15]), ('normal control', {'start': 28, 'end': 56, 'pauses': [[45, 57], [44, 58], [33, 35], [48, 63]]}, [70, 14]), ('normal control', {'start': 12, 'end': 40, 'pauses': []}, [40, 0])], [('regression', {'start': 60, 'end': 88, 'pauses': [[92, 102], [57, 65], [85, 100]]}, [96, 8]), ('regression', {'start': 82, 'end': 112, 'pauses': [[76, 78], [84, 98], [94, 101], [102, 113]]}, [139, 27]), ('partial-repair probe', {'start': 94, 'end': 124, 'pauses': [[96, 99], [128, 143], [115, 130]]}, [136, 12]), ('partial-repair probe', {'start': 15, 'end': 45, 'pauses': [[45, 52], [44, 46], [45, 45], [49, 53]]}, [46, 1]), ('normal control', {'start': 73, 'end': 101, 'pauses': [[82, 97], [85, 93], [79, 80], [82, 85]]}, [117, 16]), ('normal control', {'start': 46, 'end': 76, 'pauses': [[72, 81]]}, [80, 4]), ('normal control', {'start': 92, 'end': 122, 'pauses': [[121, 121]]}, [122, 0]), ('normal control', {'start': 26, 'end': 56, 'pauses': []}, [56, 0])], [('regression', {'start': 94, 'end': 124, 'pauses': [[96, 99], [128, 143], [115, 130]]}, [136, 12]), ('regression', {'start': 100, 'end': 131, 'pauses': [[127, 128], [119, 120], [97, 98], [120, 128]]}, [140, 9]), ('partial-repair probe', {'start': 70, 'end': 100, 'pauses': [[79, 85], [103, 107]]}, [106, 6]), ('partial-repair probe', {'start': 30, 'end': 60, 'pauses': [[64, 71], [24, 29]]}, [60, 0]), ('normal control', {'start': 44, 'end': 72, 'pauses': [[58, 64], [45, 58], [59, 70], [41, 49]]}, [98, 26]), ('normal control', {'start': 84, 'end': 115, 'pauses': []}, [115, 0]), ('normal control', {'start': 86, 'end': 114, 'pauses': [[113, 121]]}, [115, 1]), ('normal control', {'start': 98, 'end': 126, 'pauses': [[121, 127], [123, 125]]}, [131, 5])], [('regression', {'start': 15, 'end': 45, 'pauses': [[45, 52], [44, 46], [45, 45], [49, 53]]}, [46, 1]), ('regression', {'start': 92, 'end': 120, 'pauses': [[82, 91]]}, [120, 0]), ('partial-repair probe', {'start': 61, 'end': 92, 'pauses': [[95, 108], [74, 88], [60, 67]]}, [112, 20]), ('partial-repair probe', {'start': 78, 'end': 106, 'pauses': [[109, 124]]}, [106, 0]), ('normal control', {'start': 96, 'end': 124, 'pauses': [[120, 128], [90, 105], [99, 105], [116, 125]]}, [141, 17]), ('normal control', {'start': 28, 'end': 56, 'pauses': [[35, 37], [21, 36]]}, [65, 9]), ('normal control', {'start': 14, 'end': 42, 'pauses': []}, [42, 0]), ('normal control', {'start': 56, 'end': 86, 'pauses': []}, [86, 0])], [('regression', {'start': 70, 'end': 100, 'pauses': [[79, 85], [103, 107]]}, [106, 6]), ('regression', {'start': 0, 'end': 31, 'pauses': [[31, 46], [24, 33], [-7, -3], [-8, 6]]}, [44, 13]), ('partial-repair probe', {'start': 74, 'end': 104, 'pauses': [[91, 106], [66, 68], [108, 111], [108, 119]]}, [117, 13]), ('partial-repair probe', {'start': 2, 'end': 33, 'pauses': [[34, 37], [22, 34], [-7, -2], [32, 33]]}, [44, 11]), ('normal control', {'start': 94, 'end': 125, 'pauses': [[103, 112], [94, 95], [111, 118], [87, 100]]}, [146, 21]), ('normal control', {'start': 19, 'end': 49, 'pauses': [[17, 21], [22, 37], [42, 42]]}, [66, 17]), ('normal control', {'start': 65, 'end': 93, 'pauses': []}, [93, 0]), ('normal control', {'start': 84, 'end': 114, 'pauses': [[96, 100], [88, 96], [80, 90]]}, [130, 16])]]
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[130, 14][131, 15]Failed
regression 1[65, 0][65, 0]Passed
partial-repair probe 2[92, 4][96, 8]Failed
partial-repair probe 3[132, 8][136, 12]Failed
normal control 4[58, 10][58, 10]Passed
normal control 5[60, 15][60, 15]Passed
normal control 6[70, 14][70, 14]Passed
normal control 7[40, 0][40, 0]Passed

SHA-256 / 401a670df3bb0ae10829292865ad9f87b1a8b510415a6e9a576f62d516c69296

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    s, e = x['start'], x['end']
    iv = sorted([max(a, s), min(b, e)] for a, b in x['pauses'])
    iv = [p for p in iv if p[0] < p[1]]
    merged = []
    for a, b in iv:
        if merged and a <= merged[-1][1]:
            merged[-1][1] = max(merged[-1][1], b)
        else:
            merged.append([a, b])
    paused = sum(b - a for a, b in merged)
    return [e + paused, paused]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'start': 86, 'end': 116, 'pauses': [[89, 104], [117, 132], [97, 102]]}, [131, 15]), ('regression', {'start': 34, 'end': 65, 'pauses': [[30, 33], [31, 34]]}, [65, 0]), ('partial-repair probe', {'start': 60, 'end': 88, 'pauses': [[92, 102], [57, 65], [85, 100]]}, [96, 8]), ('partial-repair probe', {'start': 94, 'end': 124, 'pauses': [[96, 99], [128, 143], [115, 130]]}, [136, 12]), ('normal control', {'start': 20, 'end': 48, 'pauses': [[28, 28], [16, 30], [23, 23]]}, [58, 10]), ('normal control', {'start': 15, 'end': 45, 'pauses': [[20, 34], [22, 25], [25, 35]]}, [60, 15]), ('normal control', {'start': 28, 'end': 56, 'pauses': [[45, 57], [44, 58], [33, 35], [48, 63]]}, [70, 14]), ('normal control', {'start': 12, 'end': 40, 'pauses': []}, [40, 0])], [('regression', {'start': 60, 'end': 88, 'pauses': [[92, 102], [57, 65], [85, 100]]}, [96, 8]), ('regression', {'start': 82, 'end': 112, 'pauses': [[76, 78], [84, 98], [94, 101], [102, 113]]}, [139, 27]), ('partial-repair probe', {'start': 94, 'end': 124, 'pauses': [[96, 99], [128, 143], [115, 130]]}, [136, 12]), ('partial-repair probe', {'start': 15, 'end': 45, 'pauses': [[45, 52], [44, 46], [45, 45], [49, 53]]}, [46, 1]), ('normal control', {'start': 73, 'end': 101, 'pauses': [[82, 97], [85, 93], [79, 80], [82, 85]]}, [117, 16]), ('normal control', {'start': 46, 'end': 76, 'pauses': [[72, 81]]}, [80, 4]), ('normal control', {'start': 92, 'end': 122, 'pauses': [[121, 121]]}, [122, 0]), ('normal control', {'start': 26, 'end': 56, 'pauses': []}, [56, 0])], [('regression', {'start': 94, 'end': 124, 'pauses': [[96, 99], [128, 143], [115, 130]]}, [136, 12]), ('regression', {'start': 100, 'end': 131, 'pauses': [[127, 128], [119, 120], [97, 98], [120, 128]]}, [140, 9]), ('partial-repair probe', {'start': 70, 'end': 100, 'pauses': [[79, 85], [103, 107]]}, [106, 6]), ('partial-repair probe', {'start': 30, 'end': 60, 'pauses': [[64, 71], [24, 29]]}, [60, 0]), ('normal control', {'start': 44, 'end': 72, 'pauses': [[58, 64], [45, 58], [59, 70], [41, 49]]}, [98, 26]), ('normal control', {'start': 84, 'end': 115, 'pauses': []}, [115, 0]), ('normal control', {'start': 86, 'end': 114, 'pauses': [[113, 121]]}, [115, 1]), ('normal control', {'start': 98, 'end': 126, 'pauses': [[121, 127], [123, 125]]}, [131, 5])], [('regression', {'start': 15, 'end': 45, 'pauses': [[45, 52], [44, 46], [45, 45], [49, 53]]}, [46, 1]), ('regression', {'start': 92, 'end': 120, 'pauses': [[82, 91]]}, [120, 0]), ('partial-repair probe', {'start': 61, 'end': 92, 'pauses': [[95, 108], [74, 88], [60, 67]]}, [112, 20]), ('partial-repair probe', {'start': 78, 'end': 106, 'pauses': [[109, 124]]}, [106, 0]), ('normal control', {'start': 96, 'end': 124, 'pauses': [[120, 128], [90, 105], [99, 105], [116, 125]]}, [141, 17]), ('normal control', {'start': 28, 'end': 56, 'pauses': [[35, 37], [21, 36]]}, [65, 9]), ('normal control', {'start': 14, 'end': 42, 'pauses': []}, [42, 0]), ('normal control', {'start': 56, 'end': 86, 'pauses': []}, [86, 0])], [('regression', {'start': 70, 'end': 100, 'pauses': [[79, 85], [103, 107]]}, [106, 6]), ('regression', {'start': 0, 'end': 31, 'pauses': [[31, 46], [24, 33], [-7, -3], [-8, 6]]}, [44, 13]), ('partial-repair probe', {'start': 74, 'end': 104, 'pauses': [[91, 106], [66, 68], [108, 111], [108, 119]]}, [117, 13]), ('partial-repair probe', {'start': 2, 'end': 33, 'pauses': [[34, 37], [22, 34], [-7, -2], [32, 33]]}, [44, 11]), ('normal control', {'start': 94, 'end': 125, 'pauses': [[103, 112], [94, 95], [111, 118], [87, 100]]}, [146, 21]), ('normal control', {'start': 19, 'end': 49, 'pauses': [[17, 21], [22, 37], [42, 42]]}, [66, 17]), ('normal control', {'start': 65, 'end': 93, 'pauses': []}, [93, 0]), ('normal control', {'start': 84, 'end': 114, 'pauses': [[96, 100], [88, 96], [80, 90]]}, [130, 16])]]
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[131, 15][131, 15]Passed
regression 1[65, 0][65, 0]Passed
partial-repair probe 2[96, 8][96, 8]Passed
partial-repair probe 3[136, 12][136, 12]Passed
normal control 4[58, 10][58, 10]Passed
normal control 5[60, 15][60, 15]Passed
normal control 6[70, 14][70, 14]Passed
normal control 7[40, 0][40, 0]Passed

SHA-256 / 425c52114f9791907d00de4bd0d54658e2c1a288854d478f17c780b3c4d57ef9

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

Case digest / 08dd5203c286190d974f84d4a03bac7b713fb4c91bb44418f2f3d8fdd27d68ed