FAILURE MAP
← Case archive

FA-59646 / Subscription proration billing / Open access

Minimum threshold for invoicing prorations: invoice threshold · case 01

Pending amounts exactly at the threshold are carried instead of invoiced.

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

ROOT CAUSE

The invoice test is exclusive at the threshold.

VERIFIED REPAIR

Restore the contract rule at the invoice threshold step: use `if pending >= x['threshold']:`.

Unsuccessful approach: The attempt uses the magnitude, invoicing large credits as negative charges.

Case contract

Input {lines, threshold, carried}. Pending = carried + sum(lines). Pending >= threshold is invoiced now; pending <= -threshold is credited to the balance now; anything in between is carried to the next cycle. Return [invoiced, credited, carry].

Why this case matters

Tiny proration amounts are deferred to avoid micro-charges, but must not be lost.

1 / The failure

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

N = 1
observations = []
def solve(x):
    pending = x['carried'] + sum(x['lines'])
    if pending > x['threshold']:
        return [pending, 0, 0]
    if pending <= -x['threshold']:
        return [0, -pending, 0]
    return [0, 0, pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression (boundary)', {'lines': [30], 'threshold': 50, 'carried': 20}, [50, 0, 0]), ('regression (boundary)', {'lines': [], 'threshold': 100, 'carried': 100}, [100, 0, 0]), ('partial-repair probe (boundary)', {'lines': [-100], 'threshold': 100, 'carried': 0}, [0, 100, 0]), ('partial-repair probe (boundary)', {'lines': [-60], 'threshold': 50, 'carried': 10}, [0, 50, 0]), ('normal control', {'lines': [61, 426, -138, 400], 'threshold': 50, 'carried': 0}, [749, 0, 0]), ('normal control', {'lines': [], 'threshold': 500, 'carried': 499}, [0, 0, 499]), ('normal control', {'lines': [518, -386], 'threshold': 500, 'carried': 499}, [631, 0, 0]), ('normal control', {'lines': [-381, 116], 'threshold': 500, 'carried': 0}, [0, 0, -265])], [('regression (boundary)', {'lines': [], 'threshold': 100, 'carried': 100}, [100, 0, 0]), ('regression (boundary)', {'lines': [250, 250], 'threshold': 500, 'carried': 0}, [500, 0, 0]), ('partial-repair probe', {'lines': [340, -379, -241], 'threshold': 50, 'carried': -6}, [0, 286, 0]), ('partial-repair probe', {'lines': [-497, -497, -32, -352], 'threshold': 50, 'carried': -49}, [0, 1427, 0]), ('normal control', {'lines': [], 'threshold': 500, 'carried': -499}, [0, 0, -499]), ('normal control', {'lines': [-95, 305], 'threshold': 100, 'carried': 0}, [210, 0, 0]), ('normal control', {'lines': [145, -201, 592, 509], 'threshold': 500, 'carried': 0}, [1045, 0, 0]), ('normal control', {'lines': [382, -579, 100], 'threshold': 500, 'carried': 299}, [0, 0, 202])], [('regression (boundary)', {'lines': [250, 250], 'threshold': 500, 'carried': 0}, [500, 0, 0]), ('regression (boundary)', {'lines': [-50, 150], 'threshold': 100, 'carried': 0}, [100, 0, 0]), ('partial-repair probe', {'lines': [2, -134, -347, 119], 'threshold': 50, 'carried': 0}, [0, 360, 0]), ('partial-repair probe', {'lines': [-325], 'threshold': 500, 'carried': -499}, [0, 824, 0]), ('normal control', {'lines': [3], 'threshold': 100, 'carried': 49}, [0, 0, 52]), ('normal control', {'lines': [481], 'threshold': 100, 'carried': 0}, [481, 0, 0]), ('normal control', {'lines': [184, -104], 'threshold': 50, 'carried': 0}, [80, 0, 0]), ('normal control', {'lines': [131], 'threshold': 100, 'carried': 99}, [230, 0, 0])], [('regression (boundary)', {'lines': [-50, 150], 'threshold': 100, 'carried': 0}, [100, 0, 0]), ('regression (boundary)', {'lines': [40, 10], 'threshold': 50, 'carried': 0}, [50, 0, 0]), ('partial-repair probe', {'lines': [218, -553], 'threshold': 100, 'carried': -99}, [0, 434, 0]), ('partial-repair probe', {'lines': [-336, -428, -165, 586], 'threshold': 50, 'carried': 49}, [0, 294, 0]), ('normal control', {'lines': [140, 140], 'threshold': 100, 'carried': -99}, [181, 0, 0]), ('normal control', {'lines': [], 'threshold': 50, 'carried': 49}, [0, 0, 49]), ('normal control', {'lines': [], 'threshold': 100, 'carried': -99}, [0, 0, -99]), ('normal control', {'lines': [489], 'threshold': 50, 'carried': -49}, [440, 0, 0])], [('regression (boundary)', {'lines': [40, 10], 'threshold': 50, 'carried': 0}, [50, 0, 0]), ('regression (boundary)', {'lines': [30], 'threshold': 50, 'carried': 20}, [50, 0, 0]), ('partial-repair probe', {'lines': [111, -322], 'threshold': 500, 'carried': -499}, [0, 710, 0]), ('partial-repair probe', {'lines': [-510, 83, 385, -249], 'threshold': 100, 'carried': -99}, [0, 390, 0]), ('normal control', {'lines': [], 'threshold': 50, 'carried': -41}, [0, 0, -41]), ('normal control', {'lines': [462, -187], 'threshold': 50, 'carried': 49}, [324, 0, 0]), ('normal control', {'lines': [425, 134, -443, 185], 'threshold': 100, 'carried': -99}, [202, 0, 0]), ('normal control', {'lines': [-98, 187, -568, 507], 'threshold': 100, 'carried': 99}, [127, 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 (boundary) 0[0, 0, 50][50, 0, 0]Failed
regression (boundary) 1[0, 0, 100][100, 0, 0]Failed
partial-repair probe (boundary) 2[0, 100, 0][0, 100, 0]Passed
partial-repair probe (boundary) 3[0, 50, 0][0, 50, 0]Passed
normal control 4[749, 0, 0][749, 0, 0]Passed
normal control 5[0, 0, 499][0, 0, 499]Passed
normal control 6[631, 0, 0][631, 0, 0]Passed
normal control 7[0, 0, -265][0, 0, -265]Passed

SHA-256 / bbc6b1471aea601dc45856ccf592da4798f360a96442b92ae28b4845f7195929

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    pending = x['carried'] + sum(x['lines'])
    if abs(pending) >= x['threshold']:
        return [pending, 0, 0]
    if pending <= -x['threshold']:
        return [0, -pending, 0]
    return [0, 0, pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression (boundary)', {'lines': [30], 'threshold': 50, 'carried': 20}, [50, 0, 0]), ('regression (boundary)', {'lines': [], 'threshold': 100, 'carried': 100}, [100, 0, 0]), ('partial-repair probe (boundary)', {'lines': [-100], 'threshold': 100, 'carried': 0}, [0, 100, 0]), ('partial-repair probe (boundary)', {'lines': [-60], 'threshold': 50, 'carried': 10}, [0, 50, 0]), ('normal control', {'lines': [61, 426, -138, 400], 'threshold': 50, 'carried': 0}, [749, 0, 0]), ('normal control', {'lines': [], 'threshold': 500, 'carried': 499}, [0, 0, 499]), ('normal control', {'lines': [518, -386], 'threshold': 500, 'carried': 499}, [631, 0, 0]), ('normal control', {'lines': [-381, 116], 'threshold': 500, 'carried': 0}, [0, 0, -265])], [('regression (boundary)', {'lines': [], 'threshold': 100, 'carried': 100}, [100, 0, 0]), ('regression (boundary)', {'lines': [250, 250], 'threshold': 500, 'carried': 0}, [500, 0, 0]), ('partial-repair probe', {'lines': [340, -379, -241], 'threshold': 50, 'carried': -6}, [0, 286, 0]), ('partial-repair probe', {'lines': [-497, -497, -32, -352], 'threshold': 50, 'carried': -49}, [0, 1427, 0]), ('normal control', {'lines': [], 'threshold': 500, 'carried': -499}, [0, 0, -499]), ('normal control', {'lines': [-95, 305], 'threshold': 100, 'carried': 0}, [210, 0, 0]), ('normal control', {'lines': [145, -201, 592, 509], 'threshold': 500, 'carried': 0}, [1045, 0, 0]), ('normal control', {'lines': [382, -579, 100], 'threshold': 500, 'carried': 299}, [0, 0, 202])], [('regression (boundary)', {'lines': [250, 250], 'threshold': 500, 'carried': 0}, [500, 0, 0]), ('regression (boundary)', {'lines': [-50, 150], 'threshold': 100, 'carried': 0}, [100, 0, 0]), ('partial-repair probe', {'lines': [2, -134, -347, 119], 'threshold': 50, 'carried': 0}, [0, 360, 0]), ('partial-repair probe', {'lines': [-325], 'threshold': 500, 'carried': -499}, [0, 824, 0]), ('normal control', {'lines': [3], 'threshold': 100, 'carried': 49}, [0, 0, 52]), ('normal control', {'lines': [481], 'threshold': 100, 'carried': 0}, [481, 0, 0]), ('normal control', {'lines': [184, -104], 'threshold': 50, 'carried': 0}, [80, 0, 0]), ('normal control', {'lines': [131], 'threshold': 100, 'carried': 99}, [230, 0, 0])], [('regression (boundary)', {'lines': [-50, 150], 'threshold': 100, 'carried': 0}, [100, 0, 0]), ('regression (boundary)', {'lines': [40, 10], 'threshold': 50, 'carried': 0}, [50, 0, 0]), ('partial-repair probe', {'lines': [218, -553], 'threshold': 100, 'carried': -99}, [0, 434, 0]), ('partial-repair probe', {'lines': [-336, -428, -165, 586], 'threshold': 50, 'carried': 49}, [0, 294, 0]), ('normal control', {'lines': [140, 140], 'threshold': 100, 'carried': -99}, [181, 0, 0]), ('normal control', {'lines': [], 'threshold': 50, 'carried': 49}, [0, 0, 49]), ('normal control', {'lines': [], 'threshold': 100, 'carried': -99}, [0, 0, -99]), ('normal control', {'lines': [489], 'threshold': 50, 'carried': -49}, [440, 0, 0])], [('regression (boundary)', {'lines': [40, 10], 'threshold': 50, 'carried': 0}, [50, 0, 0]), ('regression (boundary)', {'lines': [30], 'threshold': 50, 'carried': 20}, [50, 0, 0]), ('partial-repair probe', {'lines': [111, -322], 'threshold': 500, 'carried': -499}, [0, 710, 0]), ('partial-repair probe', {'lines': [-510, 83, 385, -249], 'threshold': 100, 'carried': -99}, [0, 390, 0]), ('normal control', {'lines': [], 'threshold': 50, 'carried': -41}, [0, 0, -41]), ('normal control', {'lines': [462, -187], 'threshold': 50, 'carried': 49}, [324, 0, 0]), ('normal control', {'lines': [425, 134, -443, 185], 'threshold': 100, 'carried': -99}, [202, 0, 0]), ('normal control', {'lines': [-98, 187, -568, 507], 'threshold': 100, 'carried': 99}, [127, 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 (boundary) 0[50, 0, 0][50, 0, 0]Passed
regression (boundary) 1[100, 0, 0][100, 0, 0]Passed
partial-repair probe (boundary) 2[-100, 0, 0][0, 100, 0]Failed
partial-repair probe (boundary) 3[-50, 0, 0][0, 50, 0]Failed
normal control 4[749, 0, 0][749, 0, 0]Passed
normal control 5[0, 0, 499][0, 0, 499]Passed
normal control 6[631, 0, 0][631, 0, 0]Passed
normal control 7[0, 0, -265][0, 0, -265]Passed

SHA-256 / 193801e1a0ea89e14a13d73007f718f3f83b3a59444202846ebd09a08b902b77

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    pending = x['carried'] + sum(x['lines'])
    if pending >= x['threshold']:
        return [pending, 0, 0]
    if pending <= -x['threshold']:
        return [0, -pending, 0]
    return [0, 0, pending]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression (boundary)', {'lines': [30], 'threshold': 50, 'carried': 20}, [50, 0, 0]), ('regression (boundary)', {'lines': [], 'threshold': 100, 'carried': 100}, [100, 0, 0]), ('partial-repair probe (boundary)', {'lines': [-100], 'threshold': 100, 'carried': 0}, [0, 100, 0]), ('partial-repair probe (boundary)', {'lines': [-60], 'threshold': 50, 'carried': 10}, [0, 50, 0]), ('normal control', {'lines': [61, 426, -138, 400], 'threshold': 50, 'carried': 0}, [749, 0, 0]), ('normal control', {'lines': [], 'threshold': 500, 'carried': 499}, [0, 0, 499]), ('normal control', {'lines': [518, -386], 'threshold': 500, 'carried': 499}, [631, 0, 0]), ('normal control', {'lines': [-381, 116], 'threshold': 500, 'carried': 0}, [0, 0, -265])], [('regression (boundary)', {'lines': [], 'threshold': 100, 'carried': 100}, [100, 0, 0]), ('regression (boundary)', {'lines': [250, 250], 'threshold': 500, 'carried': 0}, [500, 0, 0]), ('partial-repair probe', {'lines': [340, -379, -241], 'threshold': 50, 'carried': -6}, [0, 286, 0]), ('partial-repair probe', {'lines': [-497, -497, -32, -352], 'threshold': 50, 'carried': -49}, [0, 1427, 0]), ('normal control', {'lines': [], 'threshold': 500, 'carried': -499}, [0, 0, -499]), ('normal control', {'lines': [-95, 305], 'threshold': 100, 'carried': 0}, [210, 0, 0]), ('normal control', {'lines': [145, -201, 592, 509], 'threshold': 500, 'carried': 0}, [1045, 0, 0]), ('normal control', {'lines': [382, -579, 100], 'threshold': 500, 'carried': 299}, [0, 0, 202])], [('regression (boundary)', {'lines': [250, 250], 'threshold': 500, 'carried': 0}, [500, 0, 0]), ('regression (boundary)', {'lines': [-50, 150], 'threshold': 100, 'carried': 0}, [100, 0, 0]), ('partial-repair probe', {'lines': [2, -134, -347, 119], 'threshold': 50, 'carried': 0}, [0, 360, 0]), ('partial-repair probe', {'lines': [-325], 'threshold': 500, 'carried': -499}, [0, 824, 0]), ('normal control', {'lines': [3], 'threshold': 100, 'carried': 49}, [0, 0, 52]), ('normal control', {'lines': [481], 'threshold': 100, 'carried': 0}, [481, 0, 0]), ('normal control', {'lines': [184, -104], 'threshold': 50, 'carried': 0}, [80, 0, 0]), ('normal control', {'lines': [131], 'threshold': 100, 'carried': 99}, [230, 0, 0])], [('regression (boundary)', {'lines': [-50, 150], 'threshold': 100, 'carried': 0}, [100, 0, 0]), ('regression (boundary)', {'lines': [40, 10], 'threshold': 50, 'carried': 0}, [50, 0, 0]), ('partial-repair probe', {'lines': [218, -553], 'threshold': 100, 'carried': -99}, [0, 434, 0]), ('partial-repair probe', {'lines': [-336, -428, -165, 586], 'threshold': 50, 'carried': 49}, [0, 294, 0]), ('normal control', {'lines': [140, 140], 'threshold': 100, 'carried': -99}, [181, 0, 0]), ('normal control', {'lines': [], 'threshold': 50, 'carried': 49}, [0, 0, 49]), ('normal control', {'lines': [], 'threshold': 100, 'carried': -99}, [0, 0, -99]), ('normal control', {'lines': [489], 'threshold': 50, 'carried': -49}, [440, 0, 0])], [('regression (boundary)', {'lines': [40, 10], 'threshold': 50, 'carried': 0}, [50, 0, 0]), ('regression (boundary)', {'lines': [30], 'threshold': 50, 'carried': 20}, [50, 0, 0]), ('partial-repair probe', {'lines': [111, -322], 'threshold': 500, 'carried': -499}, [0, 710, 0]), ('partial-repair probe', {'lines': [-510, 83, 385, -249], 'threshold': 100, 'carried': -99}, [0, 390, 0]), ('normal control', {'lines': [], 'threshold': 50, 'carried': -41}, [0, 0, -41]), ('normal control', {'lines': [462, -187], 'threshold': 50, 'carried': 49}, [324, 0, 0]), ('normal control', {'lines': [425, 134, -443, 185], 'threshold': 100, 'carried': -99}, [202, 0, 0]), ('normal control', {'lines': [-98, 187, -568, 507], 'threshold': 100, 'carried': 99}, [127, 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 (boundary) 0[50, 0, 0][50, 0, 0]Passed
regression (boundary) 1[100, 0, 0][100, 0, 0]Passed
partial-repair probe (boundary) 2[0, 100, 0][0, 100, 0]Passed
partial-repair probe (boundary) 3[0, 50, 0][0, 50, 0]Passed
normal control 4[749, 0, 0][749, 0, 0]Passed
normal control 5[0, 0, 499][0, 0, 499]Passed
normal control 6[631, 0, 0][631, 0, 0]Passed
normal control 7[0, 0, -265][0, 0, -265]Passed

SHA-256 / 29b9cbfb73c505e7efd7f78d788ee36475f14d2b844d4ca874c971f9593598e6

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

Case digest / df2dec3240a3e2a4a203b56a979c122bc17aacbdd46532cebc6f73034f942d09