FA-59686 / Subscription proration billing / Open access
Volume discount tiers on quantity changes: tier for each quantity · case 01
Customers adding seats across a tier boundary keep the old tier's discount.
ROOT CAUSE
The discount tier is chosen from the old quantity for both lines.
VERIFIED REPAIR
Restore the contract rule at the tier for each quantity step: use `return q * x['unit'] * (100 - tier_pct(q))`.
Unsuccessful approach: The attempt uses the larger quantity's tier, so downgrades keep the higher discount.
Case contract
Input {unit, old, new quantities, tiers: ascending [[min_qty, pct_off]], left, period}. A quantity's discount is the pct of the last tier with qty >= min_qty and applies to all units: total(q) = q*unit*(100-pct) in cent-percent. Proration of q = total(q)*left/(100*period) half-up. Return [-proration(old), proration(new)].
Why this case matters
Crossing a volume tier on a mid-cycle quantity change re-prices every unit for the rest of the period.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
def tier_pct(q):
pct = 0
for mn, off in x['tiers']:
if q >= mn:
pct = off
return pct
def total(q):
return q * x['unit'] * (100 - tier_pct(x['old']))
def pr(q):
return (total(q) * x['left'] * 2 + 100 * x['period']) // (200 * x['period'])
return [-pr(x['old']), pr(x['new'])]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'unit': 999, 'old': 18, 'new': 1, 'tiers': [[1, 0], [8, 10], [28, 15]], 'left': 25, 'period': 31}, [-13051, 806]), ('regression', {'unit': 1396, 'old': 18, 'new': 39, 'tiers': [[1, 0], [5, 10], [31, 25]], 'left': 21, 'period': 31}, [-15320, 27661]), ('partial-repair probe', {'unit': 1500, 'old': 37, 'new': 19, 'tiers': [[1, 0], [5, 5], [28, 15]], 'left': 13, 'period': 31}, [-19783, 11354]), ('partial-repair probe', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('normal control', {'unit': 1500, 'old': 22, 'new': 32, 'tiers': [[1, 0], [5, 5], [35, 25]], 'left': 9, 'period': 31}, [-9102, 13239]), ('normal control', {'unit': 1500, 'old': 26, 'new': 40, 'tiers': [[1, 0], [7, 10], [26, 20]], 'left': 20, 'period': 31}, [-20129, 30968]), ('normal control', {'unit': 1000, 'old': 5, 'new': 17, 'tiers': [[1, 0], [5, 5], [37, 25]], 'left': 10, 'period': 31}, [-1532, 5210]), ('normal control', {'unit': 1000, 'old': 27, 'new': 46, 'tiers': [[1, 0], [9, 5], [20, 15]], 'left': 4, 'period': 31}, [-2961, 5045])], [('regression', {'unit': 1500, 'old': 37, 'new': 19, 'tiers': [[1, 0], [5, 5], [28, 15]], 'left': 13, 'period': 31}, [-19783, 11354]), ('regression', {'unit': 999, 'old': 18, 'new': 1, 'tiers': [[1, 0], [8, 10], [28, 15]], 'left': 25, 'period': 31}, [-13051, 806]), ('partial-repair probe', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('partial-repair probe', {'unit': 1500, 'old': 38, 'new': 12, 'tiers': [[1, 0], [8, 10], [31, 25]], 'left': 15, 'period': 31}, [-20685, 7839]), ('normal control', {'unit': 1000, 'old': 18, 'new': 17, 'tiers': [[1, 0], [10, 10], [32, 25]], 'left': 24, 'period': 31}, [-12542, 11845]), ('normal control', {'unit': 1000, 'old': 41, 'new': 30, 'tiers': [[1, 0], [5, 5], [20, 15]], 'left': 23, 'period': 31}, [-25856, 18919]), ('normal control', {'unit': 1000, 'old': 1, 'new': 2, 'tiers': [[1, 0], [10, 5], [21, 20]], 'left': 30, 'period': 31}, [-968, 1935]), ('normal control', {'unit': 1500, 'old': 42, 'new': 42, 'tiers': [[1, 0], [9, 10], [33, 25]], 'left': 30, 'period': 31}, [-45726, 45726])], [('regression', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('regression', {'unit': 1500, 'old': 37, 'new': 19, 'tiers': [[1, 0], [5, 5], [28, 15]], 'left': 13, 'period': 31}, [-19783, 11354]), ('partial-repair probe', {'unit': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('partial-repair probe', {'unit': 1000, 'old': 48, 'new': 14, 'tiers': [[1, 0], [9, 5], [31, 20]], 'left': 21, 'period': 31}, [-26013, 9010]), ('normal control', {'unit': 1500, 'old': 45, 'new': 35, 'tiers': [[1, 0], [9, 10], [25, 25]], 'left': 26, 'period': 31}, [-42460, 33024]), ('normal control', {'unit': 1000, 'old': 27, 'new': 21, 'tiers': [[1, 0], [8, 10], [36, 15]], 'left': 24, 'period': 31}, [-18813, 14632]), ('normal control', {'unit': 999, 'old': 24, 'new': 6, 'tiers': [[1, 0], [5, 10], [35, 15]], 'left': 27, 'period': 31}, [-18794, 4699]), ('normal control', {'unit': 999, 'old': 37, 'new': 45, 'tiers': [[1, 0], [9, 10], [25, 20]], 'left': 31, 'period': 31}, [-29570, 35964])], [('regression', {'unit': 1500, 'old': 38, 'new': 12, 'tiers': [[1, 0], [8, 10], [31, 25]], 'left': 15, 'period': 31}, [-20685, 7839]), ('regression', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('partial-repair probe', {'unit': 999, 'old': 14, 'new': 7, 'tiers': [[1, 0], [8, 10], [27, 25]], 'left': 24, 'period': 31}, [-9745, 5414]), ('partial-repair probe', {'unit': 999, 'old': 39, 'new': 26, 'tiers': [[1, 0], [7, 10], [32, 15]], 'left': 27, 'period': 31}, [-28844, 20360]), ('normal control', {'unit': 3876, 'old': 16, 'new': 37, 'tiers': [[1, 0], [6, 10], [40, 20]], 'left': 14, 'period': 31}, [-25207, 58290]), ('normal control', {'unit': 1500, 'old': 32, 'new': 32, 'tiers': [[1, 0], [5, 5], [35, 20]], 'left': 25, 'period': 31}, [-36774, 36774]), ('normal control', {'unit': 1000, 'old': 22, 'new': 25, 'tiers': [[1, 0], [9, 10], [38, 15]], 'left': 13, 'period': 31}, [-8303, 9435]), ('normal control', {'unit': 999, 'old': 32, 'new': 41, 'tiers': [[1, 0], [5, 10], [23, 15]], 'left': 13, 'period': 31}, [-11395, 14600])], [('regression', {'unit': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('regression', {'unit': 1500, 'old': 21, 'new': 45, 'tiers': [[1, 0], [7, 10], [29, 20]], 'left': 20, 'period': 31}, [-18290, 34839]), ('partial-repair probe', {'unit': 999, 'old': 10, 'new': 1, 'tiers': [[1, 0], [5, 10], [22, 15]], 'left': 29, 'period': 31}, [-8411, 935]), ('partial-repair probe', {'unit': 999, 'old': 21, 'new': 1, 'tiers': [[1, 0], [10, 5], [31, 20]], 'left': 9, 'period': 31}, [-5786, 290]), ('normal control', {'unit': 3669, 'old': 42, 'new': 45, 'tiers': [[1, 0], [8, 10], [31, 15]], 'left': 27, 'period': 31}, [-114082, 122231]), ('normal control', {'unit': 3542, 'old': 20, 'new': 15, 'tiers': [[1, 0], [10, 10], [31, 25]], 'left': 9, 'period': 31}, [-18510, 13882]), ('normal control', {'unit': 1500, 'old': 5, 'new': 29, 'tiers': [[1, 0], [5, 5], [38, 15]], 'left': 16, 'period': 31}, [-3677, 21329]), ('normal control', {'unit': 1500, 'old': 18, 'new': 18, 'tiers': [[1, 0], [9, 10], [31, 20]], 'left': 1, 'period': 31}, [-784, 784])]]
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 | [-13051, 725] | [-13051, 806] | Failed |
| regression 1 | [-15320, 33193] | [-15320, 27661] | Failed |
| partial-repair probe 2 | [-19783, 10159] | [-19783, 11354] | Failed |
| partial-repair probe 3 | [-38646, 22440] | [-38646, 28424] | Failed |
| normal control 4 | [-9102, 13239] | [-9102, 13239] | Passed |
| normal control 5 | [-20129, 30968] | [-20129, 30968] | Passed |
| normal control 6 | [-1532, 5210] | [-1532, 5210] | Passed |
| normal control 7 | [-2961, 5045] | [-2961, 5045] | Passed |
SHA-256 / bcb79c89f06d1f02793dfbd7810e3275da01e3e8987d9dc0d64f06d48debebfc
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
def tier_pct(q):
pct = 0
for mn, off in x['tiers']:
if q >= mn:
pct = off
return pct
def total(q):
return q * x['unit'] * (100 - tier_pct(max(q, x['old'])))
def pr(q):
return (total(q) * x['left'] * 2 + 100 * x['period']) // (200 * x['period'])
return [-pr(x['old']), pr(x['new'])]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'unit': 999, 'old': 18, 'new': 1, 'tiers': [[1, 0], [8, 10], [28, 15]], 'left': 25, 'period': 31}, [-13051, 806]), ('regression', {'unit': 1396, 'old': 18, 'new': 39, 'tiers': [[1, 0], [5, 10], [31, 25]], 'left': 21, 'period': 31}, [-15320, 27661]), ('partial-repair probe', {'unit': 1500, 'old': 37, 'new': 19, 'tiers': [[1, 0], [5, 5], [28, 15]], 'left': 13, 'period': 31}, [-19783, 11354]), ('partial-repair probe', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('normal control', {'unit': 1500, 'old': 22, 'new': 32, 'tiers': [[1, 0], [5, 5], [35, 25]], 'left': 9, 'period': 31}, [-9102, 13239]), ('normal control', {'unit': 1500, 'old': 26, 'new': 40, 'tiers': [[1, 0], [7, 10], [26, 20]], 'left': 20, 'period': 31}, [-20129, 30968]), ('normal control', {'unit': 1000, 'old': 5, 'new': 17, 'tiers': [[1, 0], [5, 5], [37, 25]], 'left': 10, 'period': 31}, [-1532, 5210]), ('normal control', {'unit': 1000, 'old': 27, 'new': 46, 'tiers': [[1, 0], [9, 5], [20, 15]], 'left': 4, 'period': 31}, [-2961, 5045])], [('regression', {'unit': 1500, 'old': 37, 'new': 19, 'tiers': [[1, 0], [5, 5], [28, 15]], 'left': 13, 'period': 31}, [-19783, 11354]), ('regression', {'unit': 999, 'old': 18, 'new': 1, 'tiers': [[1, 0], [8, 10], [28, 15]], 'left': 25, 'period': 31}, [-13051, 806]), ('partial-repair probe', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('partial-repair probe', {'unit': 1500, 'old': 38, 'new': 12, 'tiers': [[1, 0], [8, 10], [31, 25]], 'left': 15, 'period': 31}, [-20685, 7839]), ('normal control', {'unit': 1000, 'old': 18, 'new': 17, 'tiers': [[1, 0], [10, 10], [32, 25]], 'left': 24, 'period': 31}, [-12542, 11845]), ('normal control', {'unit': 1000, 'old': 41, 'new': 30, 'tiers': [[1, 0], [5, 5], [20, 15]], 'left': 23, 'period': 31}, [-25856, 18919]), ('normal control', {'unit': 1000, 'old': 1, 'new': 2, 'tiers': [[1, 0], [10, 5], [21, 20]], 'left': 30, 'period': 31}, [-968, 1935]), ('normal control', {'unit': 1500, 'old': 42, 'new': 42, 'tiers': [[1, 0], [9, 10], [33, 25]], 'left': 30, 'period': 31}, [-45726, 45726])], [('regression', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('regression', {'unit': 1500, 'old': 37, 'new': 19, 'tiers': [[1, 0], [5, 5], [28, 15]], 'left': 13, 'period': 31}, [-19783, 11354]), ('partial-repair probe', {'unit': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('partial-repair probe', {'unit': 1000, 'old': 48, 'new': 14, 'tiers': [[1, 0], [9, 5], [31, 20]], 'left': 21, 'period': 31}, [-26013, 9010]), ('normal control', {'unit': 1500, 'old': 45, 'new': 35, 'tiers': [[1, 0], [9, 10], [25, 25]], 'left': 26, 'period': 31}, [-42460, 33024]), ('normal control', {'unit': 1000, 'old': 27, 'new': 21, 'tiers': [[1, 0], [8, 10], [36, 15]], 'left': 24, 'period': 31}, [-18813, 14632]), ('normal control', {'unit': 999, 'old': 24, 'new': 6, 'tiers': [[1, 0], [5, 10], [35, 15]], 'left': 27, 'period': 31}, [-18794, 4699]), ('normal control', {'unit': 999, 'old': 37, 'new': 45, 'tiers': [[1, 0], [9, 10], [25, 20]], 'left': 31, 'period': 31}, [-29570, 35964])], [('regression', {'unit': 1500, 'old': 38, 'new': 12, 'tiers': [[1, 0], [8, 10], [31, 25]], 'left': 15, 'period': 31}, [-20685, 7839]), ('regression', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('partial-repair probe', {'unit': 999, 'old': 14, 'new': 7, 'tiers': [[1, 0], [8, 10], [27, 25]], 'left': 24, 'period': 31}, [-9745, 5414]), ('partial-repair probe', {'unit': 999, 'old': 39, 'new': 26, 'tiers': [[1, 0], [7, 10], [32, 15]], 'left': 27, 'period': 31}, [-28844, 20360]), ('normal control', {'unit': 3876, 'old': 16, 'new': 37, 'tiers': [[1, 0], [6, 10], [40, 20]], 'left': 14, 'period': 31}, [-25207, 58290]), ('normal control', {'unit': 1500, 'old': 32, 'new': 32, 'tiers': [[1, 0], [5, 5], [35, 20]], 'left': 25, 'period': 31}, [-36774, 36774]), ('normal control', {'unit': 1000, 'old': 22, 'new': 25, 'tiers': [[1, 0], [9, 10], [38, 15]], 'left': 13, 'period': 31}, [-8303, 9435]), ('normal control', {'unit': 999, 'old': 32, 'new': 41, 'tiers': [[1, 0], [5, 10], [23, 15]], 'left': 13, 'period': 31}, [-11395, 14600])], [('regression', {'unit': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('regression', {'unit': 1500, 'old': 21, 'new': 45, 'tiers': [[1, 0], [7, 10], [29, 20]], 'left': 20, 'period': 31}, [-18290, 34839]), ('partial-repair probe', {'unit': 999, 'old': 10, 'new': 1, 'tiers': [[1, 0], [5, 10], [22, 15]], 'left': 29, 'period': 31}, [-8411, 935]), ('partial-repair probe', {'unit': 999, 'old': 21, 'new': 1, 'tiers': [[1, 0], [10, 5], [31, 20]], 'left': 9, 'period': 31}, [-5786, 290]), ('normal control', {'unit': 3669, 'old': 42, 'new': 45, 'tiers': [[1, 0], [8, 10], [31, 15]], 'left': 27, 'period': 31}, [-114082, 122231]), ('normal control', {'unit': 3542, 'old': 20, 'new': 15, 'tiers': [[1, 0], [10, 10], [31, 25]], 'left': 9, 'period': 31}, [-18510, 13882]), ('normal control', {'unit': 1500, 'old': 5, 'new': 29, 'tiers': [[1, 0], [5, 5], [38, 15]], 'left': 16, 'period': 31}, [-3677, 21329]), ('normal control', {'unit': 1500, 'old': 18, 'new': 18, 'tiers': [[1, 0], [9, 10], [31, 20]], 'left': 1, 'period': 31}, [-784, 784])]]
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 | [-13051, 725] | [-13051, 806] | Failed |
| regression 1 | [-15320, 27661] | [-15320, 27661] | Passed |
| partial-repair probe 2 | [-19783, 10159] | [-19783, 11354] | Failed |
| partial-repair probe 3 | [-38646, 22440] | [-38646, 28424] | Failed |
| normal control 4 | [-9102, 13239] | [-9102, 13239] | Passed |
| normal control 5 | [-20129, 30968] | [-20129, 30968] | Passed |
| normal control 6 | [-1532, 5210] | [-1532, 5210] | Passed |
| normal control 7 | [-2961, 5045] | [-2961, 5045] | Passed |
SHA-256 / 4c787021b13618e5545ebd8b309e1addae5cb99716548be2bf3631d0b8de64e5
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
def tier_pct(q):
pct = 0
for mn, off in x['tiers']:
if q >= mn:
pct = off
return pct
def total(q):
return q * x['unit'] * (100 - tier_pct(q))
def pr(q):
return (total(q) * x['left'] * 2 + 100 * x['period']) // (200 * x['period'])
return [-pr(x['old']), pr(x['new'])]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'unit': 999, 'old': 18, 'new': 1, 'tiers': [[1, 0], [8, 10], [28, 15]], 'left': 25, 'period': 31}, [-13051, 806]), ('regression', {'unit': 1396, 'old': 18, 'new': 39, 'tiers': [[1, 0], [5, 10], [31, 25]], 'left': 21, 'period': 31}, [-15320, 27661]), ('partial-repair probe', {'unit': 1500, 'old': 37, 'new': 19, 'tiers': [[1, 0], [5, 5], [28, 15]], 'left': 13, 'period': 31}, [-19783, 11354]), ('partial-repair probe', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('normal control', {'unit': 1500, 'old': 22, 'new': 32, 'tiers': [[1, 0], [5, 5], [35, 25]], 'left': 9, 'period': 31}, [-9102, 13239]), ('normal control', {'unit': 1500, 'old': 26, 'new': 40, 'tiers': [[1, 0], [7, 10], [26, 20]], 'left': 20, 'period': 31}, [-20129, 30968]), ('normal control', {'unit': 1000, 'old': 5, 'new': 17, 'tiers': [[1, 0], [5, 5], [37, 25]], 'left': 10, 'period': 31}, [-1532, 5210]), ('normal control', {'unit': 1000, 'old': 27, 'new': 46, 'tiers': [[1, 0], [9, 5], [20, 15]], 'left': 4, 'period': 31}, [-2961, 5045])], [('regression', {'unit': 1500, 'old': 37, 'new': 19, 'tiers': [[1, 0], [5, 5], [28, 15]], 'left': 13, 'period': 31}, [-19783, 11354]), ('regression', {'unit': 999, 'old': 18, 'new': 1, 'tiers': [[1, 0], [8, 10], [28, 15]], 'left': 25, 'period': 31}, [-13051, 806]), ('partial-repair probe', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('partial-repair probe', {'unit': 1500, 'old': 38, 'new': 12, 'tiers': [[1, 0], [8, 10], [31, 25]], 'left': 15, 'period': 31}, [-20685, 7839]), ('normal control', {'unit': 1000, 'old': 18, 'new': 17, 'tiers': [[1, 0], [10, 10], [32, 25]], 'left': 24, 'period': 31}, [-12542, 11845]), ('normal control', {'unit': 1000, 'old': 41, 'new': 30, 'tiers': [[1, 0], [5, 5], [20, 15]], 'left': 23, 'period': 31}, [-25856, 18919]), ('normal control', {'unit': 1000, 'old': 1, 'new': 2, 'tiers': [[1, 0], [10, 5], [21, 20]], 'left': 30, 'period': 31}, [-968, 1935]), ('normal control', {'unit': 1500, 'old': 42, 'new': 42, 'tiers': [[1, 0], [9, 10], [33, 25]], 'left': 30, 'period': 31}, [-45726, 45726])], [('regression', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('regression', {'unit': 1500, 'old': 37, 'new': 19, 'tiers': [[1, 0], [5, 5], [28, 15]], 'left': 13, 'period': 31}, [-19783, 11354]), ('partial-repair probe', {'unit': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('partial-repair probe', {'unit': 1000, 'old': 48, 'new': 14, 'tiers': [[1, 0], [9, 5], [31, 20]], 'left': 21, 'period': 31}, [-26013, 9010]), ('normal control', {'unit': 1500, 'old': 45, 'new': 35, 'tiers': [[1, 0], [9, 10], [25, 25]], 'left': 26, 'period': 31}, [-42460, 33024]), ('normal control', {'unit': 1000, 'old': 27, 'new': 21, 'tiers': [[1, 0], [8, 10], [36, 15]], 'left': 24, 'period': 31}, [-18813, 14632]), ('normal control', {'unit': 999, 'old': 24, 'new': 6, 'tiers': [[1, 0], [5, 10], [35, 15]], 'left': 27, 'period': 31}, [-18794, 4699]), ('normal control', {'unit': 999, 'old': 37, 'new': 45, 'tiers': [[1, 0], [9, 10], [25, 20]], 'left': 31, 'period': 31}, [-29570, 35964])], [('regression', {'unit': 1500, 'old': 38, 'new': 12, 'tiers': [[1, 0], [8, 10], [31, 25]], 'left': 15, 'period': 31}, [-20685, 7839]), ('regression', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('partial-repair probe', {'unit': 999, 'old': 14, 'new': 7, 'tiers': [[1, 0], [8, 10], [27, 25]], 'left': 24, 'period': 31}, [-9745, 5414]), ('partial-repair probe', {'unit': 999, 'old': 39, 'new': 26, 'tiers': [[1, 0], [7, 10], [32, 15]], 'left': 27, 'period': 31}, [-28844, 20360]), ('normal control', {'unit': 3876, 'old': 16, 'new': 37, 'tiers': [[1, 0], [6, 10], [40, 20]], 'left': 14, 'period': 31}, [-25207, 58290]), ('normal control', {'unit': 1500, 'old': 32, 'new': 32, 'tiers': [[1, 0], [5, 5], [35, 20]], 'left': 25, 'period': 31}, [-36774, 36774]), ('normal control', {'unit': 1000, 'old': 22, 'new': 25, 'tiers': [[1, 0], [9, 10], [38, 15]], 'left': 13, 'period': 31}, [-8303, 9435]), ('normal control', {'unit': 999, 'old': 32, 'new': 41, 'tiers': [[1, 0], [5, 10], [23, 15]], 'left': 13, 'period': 31}, [-11395, 14600])], [('regression', {'unit': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('regression', {'unit': 1500, 'old': 21, 'new': 45, 'tiers': [[1, 0], [7, 10], [29, 20]], 'left': 20, 'period': 31}, [-18290, 34839]), ('partial-repair probe', {'unit': 999, 'old': 10, 'new': 1, 'tiers': [[1, 0], [5, 10], [22, 15]], 'left': 29, 'period': 31}, [-8411, 935]), ('partial-repair probe', {'unit': 999, 'old': 21, 'new': 1, 'tiers': [[1, 0], [10, 5], [31, 20]], 'left': 9, 'period': 31}, [-5786, 290]), ('normal control', {'unit': 3669, 'old': 42, 'new': 45, 'tiers': [[1, 0], [8, 10], [31, 15]], 'left': 27, 'period': 31}, [-114082, 122231]), ('normal control', {'unit': 3542, 'old': 20, 'new': 15, 'tiers': [[1, 0], [10, 10], [31, 25]], 'left': 9, 'period': 31}, [-18510, 13882]), ('normal control', {'unit': 1500, 'old': 5, 'new': 29, 'tiers': [[1, 0], [5, 5], [38, 15]], 'left': 16, 'period': 31}, [-3677, 21329]), ('normal control', {'unit': 1500, 'old': 18, 'new': 18, 'tiers': [[1, 0], [9, 10], [31, 20]], 'left': 1, 'period': 31}, [-784, 784])]]
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 | [-13051, 806] | [-13051, 806] | Passed |
| regression 1 | [-15320, 27661] | [-15320, 27661] | Passed |
| partial-repair probe 2 | [-19783, 11354] | [-19783, 11354] | Passed |
| partial-repair probe 3 | [-38646, 28424] | [-38646, 28424] | Passed |
| normal control 4 | [-9102, 13239] | [-9102, 13239] | Passed |
| normal control 5 | [-20129, 30968] | [-20129, 30968] | Passed |
| normal control 6 | [-1532, 5210] | [-1532, 5210] | Passed |
| normal control 7 | [-2961, 5045] | [-2961, 5045] | Passed |
SHA-256 / 0b1bb5100388265c5da09d0d7f47dd868683a0a008050ea8f296f8353a32acdc
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.652977+00:00.
Case digest / d781bfdd0de36f5979f80b3d68e1f4138a46b2ddf8ea67d20ded0d3b63f2a919