FA-59696 / Subscription proration billing / Open access
Volume discount tiers on quantity changes: discounted unit rounding · case 01
Discounted prorations drift by cents proportional to the quantity.
ROOT CAUSE
The discounted unit price is rounded to cents before multiplying by quantity.
VERIFIED REPAIR
Restore the contract rule at the discounted unit rounding step: use `return q * x['unit'] * (100 - tier_pct(q))`.
Unsuccessful approach: The attempt truncates the discounted unit price instead, still rounding before quantity.
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(q)) + 50) // 100) * 100
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': 1396, 'old': 18, 'new': 39, 'tiers': [[1, 0], [5, 10], [31, 25]], 'left': 21, 'period': 31}, [-15320, 27661]), ('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': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('normal control', {'unit': 1500, 'old': 37, 'new': 19, 'tiers': [[1, 0], [5, 5], [28, 15]], 'left': 13, 'period': 31}, [-19783, 11354]), ('normal control', {'unit': 1500, 'old': 21, 'new': 45, 'tiers': [[1, 0], [7, 10], [29, 20]], 'left': 20, 'period': 31}, [-18290, 34839]), ('normal control', {'unit': 1000, 'old': 9, 'new': 22, 'tiers': [[1, 0], [8, 5], [22, 20]], 'left': 24, 'period': 31}, [-6619, 13626]), ('normal control', {'unit': 999, 'old': 1, 'new': 19, 'tiers': [[1, 0], [10, 5], [31, 25]], 'left': 1, 'period': 31}, [-32, 582])], [('regression', {'unit': 999, 'old': 18, 'new': 1, 'tiers': [[1, 0], [8, 10], [28, 15]], 'left': 25, 'period': 31}, [-13051, 806]), ('regression', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('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': 999, 'old': 14, 'new': 7, 'tiers': [[1, 0], [8, 10], [27, 25]], 'left': 24, 'period': 31}, [-9745, 5414]), ('normal control', {'unit': 1500, 'old': 38, 'new': 12, 'tiers': [[1, 0], [8, 10], [31, 25]], 'left': 15, 'period': 31}, [-20685, 7839]), ('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': 6, 'new': 44, 'tiers': [[1, 0], [10, 10], [22, 15]], 'left': 22, 'period': 31}, [-6387, 39813]), ('normal control', {'unit': 1000, 'old': 48, 'new': 14, 'tiers': [[1, 0], [9, 5], [31, 20]], 'left': 21, 'period': 31}, [-26013, 9010])], [('regression', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('regression', {'unit': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('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': 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]), ('normal control', {'unit': 1000, 'old': 18, 'new': 17, 'tiers': [[1, 0], [10, 10], [32, 25]], 'left': 24, 'period': 31}, [-12542, 11845])], [('regression', {'unit': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('regression', {'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': 9, 'new': 38, 'tiers': [[1, 0], [6, 5], [32, 15]], 'left': 27, 'period': 31}, [-7439, 28104]), ('partial-repair probe', {'unit': 999, 'old': 10, 'new': 1, 'tiers': [[1, 0], [5, 10], [22, 15]], 'left': 29, 'period': 31}, [-8411, 935]), ('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]), ('normal control', {'unit': 1500, 'old': 45, 'new': 35, 'tiers': [[1, 0], [9, 10], [25, 25]], 'left': 26, 'period': 31}, [-42460, 33024])], [('regression', {'unit': 999, 'old': 14, 'new': 7, 'tiers': [[1, 0], [8, 10], [27, 25]], 'left': 24, 'period': 31}, [-9745, 5414]), ('regression', {'unit': 999, 'old': 39, 'new': 26, 'tiers': [[1, 0], [7, 10], [32, 15]], 'left': 27, 'period': 31}, [-28844, 20360]), ('partial-repair probe', {'unit': 999, 'old': 24, 'new': 6, 'tiers': [[1, 0], [5, 10], [35, 15]], 'left': 27, 'period': 31}, [-18794, 4699]), ('partial-repair probe', {'unit': 999, 'old': 37, 'new': 45, 'tiers': [[1, 0], [9, 10], [25, 20]], 'left': 31, 'period': 31}, [-29570, 35964]), ('normal control', {'unit': 999, 'old': 21, 'new': 1, 'tiers': [[1, 0], [10, 5], [31, 20]], 'left': 9, 'period': 31}, [-5786, 290]), ('normal control', {'unit': 1000, 'old': 27, 'new': 21, 'tiers': [[1, 0], [8, 10], [36, 15]], 'left': 24, 'period': 31}, [-18813, 14632]), ('normal control', {'unit': 1000, 'old': 4, 'new': 9, 'tiers': [[1, 0], [6, 10], [23, 20]], 'left': 30, 'period': 31}, [-3871, 7839]), ('normal control', {'unit': 1000, 'old': 26, 'new': 40, 'tiers': [[1, 0], [5, 5], [36, 25]], 'left': 25, 'period': 31}, [-19919, 24194])]]
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 | [-15315, 27661] | [-15320, 27661] | Failed |
| regression 1 | [-13050, 806] | [-13051, 806] | Failed |
| partial-repair probe 2 | [-38652, 28421] | [-38646, 28424] | Failed |
| partial-repair probe 3 | [-38212, 16503] | [-38214, 16502] | Failed |
| normal control 4 | [-19783, 11354] | [-19783, 11354] | Passed |
| normal control 5 | [-18290, 34839] | [-18290, 34839] | Passed |
| normal control 6 | [-6619, 13626] | [-6619, 13626] | Passed |
| normal control 7 | [-32, 582] | [-32, 582] | Passed |
SHA-256 / 47d81172c6f9d909707f987203f0778e1b4a0585bd262cf9dd61fe82c4da2f03
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(q)) // 100) * 100
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': 1396, 'old': 18, 'new': 39, 'tiers': [[1, 0], [5, 10], [31, 25]], 'left': 21, 'period': 31}, [-15320, 27661]), ('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': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('normal control', {'unit': 1500, 'old': 37, 'new': 19, 'tiers': [[1, 0], [5, 5], [28, 15]], 'left': 13, 'period': 31}, [-19783, 11354]), ('normal control', {'unit': 1500, 'old': 21, 'new': 45, 'tiers': [[1, 0], [7, 10], [29, 20]], 'left': 20, 'period': 31}, [-18290, 34839]), ('normal control', {'unit': 1000, 'old': 9, 'new': 22, 'tiers': [[1, 0], [8, 5], [22, 20]], 'left': 24, 'period': 31}, [-6619, 13626]), ('normal control', {'unit': 999, 'old': 1, 'new': 19, 'tiers': [[1, 0], [10, 5], [31, 25]], 'left': 1, 'period': 31}, [-32, 582])], [('regression', {'unit': 999, 'old': 18, 'new': 1, 'tiers': [[1, 0], [8, 10], [28, 15]], 'left': 25, 'period': 31}, [-13051, 806]), ('regression', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('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': 999, 'old': 14, 'new': 7, 'tiers': [[1, 0], [8, 10], [27, 25]], 'left': 24, 'period': 31}, [-9745, 5414]), ('normal control', {'unit': 1500, 'old': 38, 'new': 12, 'tiers': [[1, 0], [8, 10], [31, 25]], 'left': 15, 'period': 31}, [-20685, 7839]), ('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': 6, 'new': 44, 'tiers': [[1, 0], [10, 10], [22, 15]], 'left': 22, 'period': 31}, [-6387, 39813]), ('normal control', {'unit': 1000, 'old': 48, 'new': 14, 'tiers': [[1, 0], [9, 5], [31, 20]], 'left': 21, 'period': 31}, [-26013, 9010])], [('regression', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('regression', {'unit': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('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': 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]), ('normal control', {'unit': 1000, 'old': 18, 'new': 17, 'tiers': [[1, 0], [10, 10], [32, 25]], 'left': 24, 'period': 31}, [-12542, 11845])], [('regression', {'unit': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('regression', {'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': 9, 'new': 38, 'tiers': [[1, 0], [6, 5], [32, 15]], 'left': 27, 'period': 31}, [-7439, 28104]), ('partial-repair probe', {'unit': 999, 'old': 10, 'new': 1, 'tiers': [[1, 0], [5, 10], [22, 15]], 'left': 29, 'period': 31}, [-8411, 935]), ('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]), ('normal control', {'unit': 1500, 'old': 45, 'new': 35, 'tiers': [[1, 0], [9, 10], [25, 25]], 'left': 26, 'period': 31}, [-42460, 33024])], [('regression', {'unit': 999, 'old': 14, 'new': 7, 'tiers': [[1, 0], [8, 10], [27, 25]], 'left': 24, 'period': 31}, [-9745, 5414]), ('regression', {'unit': 999, 'old': 39, 'new': 26, 'tiers': [[1, 0], [7, 10], [32, 15]], 'left': 27, 'period': 31}, [-28844, 20360]), ('partial-repair probe', {'unit': 999, 'old': 24, 'new': 6, 'tiers': [[1, 0], [5, 10], [35, 15]], 'left': 27, 'period': 31}, [-18794, 4699]), ('partial-repair probe', {'unit': 999, 'old': 37, 'new': 45, 'tiers': [[1, 0], [9, 10], [25, 20]], 'left': 31, 'period': 31}, [-29570, 35964]), ('normal control', {'unit': 999, 'old': 21, 'new': 1, 'tiers': [[1, 0], [10, 5], [31, 20]], 'left': 9, 'period': 31}, [-5786, 290]), ('normal control', {'unit': 1000, 'old': 27, 'new': 21, 'tiers': [[1, 0], [8, 10], [36, 15]], 'left': 24, 'period': 31}, [-18813, 14632]), ('normal control', {'unit': 1000, 'old': 4, 'new': 9, 'tiers': [[1, 0], [6, 10], [23, 20]], 'left': 30, 'period': 31}, [-3871, 7839]), ('normal control', {'unit': 1000, 'old': 26, 'new': 40, 'tiers': [[1, 0], [5, 5], [36, 25]], 'left': 25, 'period': 31}, [-19919, 24194])]]
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 | [-15315, 27661] | [-15320, 27661] | Failed |
| regression 1 | [-13050, 806] | [-13051, 806] | Failed |
| partial-repair probe 2 | [-38640, 28421] | [-38646, 28424] | Failed |
| partial-repair probe 3 | [-38212, 16499] | [-38214, 16502] | Failed |
| normal control 4 | [-19783, 11354] | [-19783, 11354] | Passed |
| normal control 5 | [-18290, 34839] | [-18290, 34839] | Passed |
| normal control 6 | [-6619, 13626] | [-6619, 13626] | Passed |
| normal control 7 | [-32, 582] | [-32, 582] | Passed |
SHA-256 / b87831a39da779c0aafda10c1c42cc065909d8b37ea2b5624c6b1b665220c3c8
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': 1396, 'old': 18, 'new': 39, 'tiers': [[1, 0], [5, 10], [31, 25]], 'left': 21, 'period': 31}, [-15320, 27661]), ('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': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('normal control', {'unit': 1500, 'old': 37, 'new': 19, 'tiers': [[1, 0], [5, 5], [28, 15]], 'left': 13, 'period': 31}, [-19783, 11354]), ('normal control', {'unit': 1500, 'old': 21, 'new': 45, 'tiers': [[1, 0], [7, 10], [29, 20]], 'left': 20, 'period': 31}, [-18290, 34839]), ('normal control', {'unit': 1000, 'old': 9, 'new': 22, 'tiers': [[1, 0], [8, 5], [22, 20]], 'left': 24, 'period': 31}, [-6619, 13626]), ('normal control', {'unit': 999, 'old': 1, 'new': 19, 'tiers': [[1, 0], [10, 5], [31, 25]], 'left': 1, 'period': 31}, [-32, 582])], [('regression', {'unit': 999, 'old': 18, 'new': 1, 'tiers': [[1, 0], [8, 10], [28, 15]], 'left': 25, 'period': 31}, [-13051, 806]), ('regression', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('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': 999, 'old': 14, 'new': 7, 'tiers': [[1, 0], [8, 10], [27, 25]], 'left': 24, 'period': 31}, [-9745, 5414]), ('normal control', {'unit': 1500, 'old': 38, 'new': 12, 'tiers': [[1, 0], [8, 10], [31, 25]], 'left': 15, 'period': 31}, [-20685, 7839]), ('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': 6, 'new': 44, 'tiers': [[1, 0], [10, 10], [22, 15]], 'left': 22, 'period': 31}, [-6387, 39813]), ('normal control', {'unit': 1000, 'old': 48, 'new': 14, 'tiers': [[1, 0], [9, 5], [31, 20]], 'left': 21, 'period': 31}, [-26013, 9010])], [('regression', {'unit': 4294, 'old': 31, 'new': 18, 'tiers': [[1, 0], [10, 5], [21, 25]], 'left': 12, 'period': 31}, [-38646, 28424]), ('regression', {'unit': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('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': 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]), ('normal control', {'unit': 1000, 'old': 18, 'new': 17, 'tiers': [[1, 0], [10, 10], [32, 25]], 'left': 24, 'period': 31}, [-12542, 11845])], [('regression', {'unit': 4525, 'old': 44, 'new': 17, 'tiers': [[1, 0], [5, 5], [26, 15]], 'left': 7, 'period': 31}, [-38214, 16502]), ('regression', {'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': 9, 'new': 38, 'tiers': [[1, 0], [6, 5], [32, 15]], 'left': 27, 'period': 31}, [-7439, 28104]), ('partial-repair probe', {'unit': 999, 'old': 10, 'new': 1, 'tiers': [[1, 0], [5, 10], [22, 15]], 'left': 29, 'period': 31}, [-8411, 935]), ('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]), ('normal control', {'unit': 1500, 'old': 45, 'new': 35, 'tiers': [[1, 0], [9, 10], [25, 25]], 'left': 26, 'period': 31}, [-42460, 33024])], [('regression', {'unit': 999, 'old': 14, 'new': 7, 'tiers': [[1, 0], [8, 10], [27, 25]], 'left': 24, 'period': 31}, [-9745, 5414]), ('regression', {'unit': 999, 'old': 39, 'new': 26, 'tiers': [[1, 0], [7, 10], [32, 15]], 'left': 27, 'period': 31}, [-28844, 20360]), ('partial-repair probe', {'unit': 999, 'old': 24, 'new': 6, 'tiers': [[1, 0], [5, 10], [35, 15]], 'left': 27, 'period': 31}, [-18794, 4699]), ('partial-repair probe', {'unit': 999, 'old': 37, 'new': 45, 'tiers': [[1, 0], [9, 10], [25, 20]], 'left': 31, 'period': 31}, [-29570, 35964]), ('normal control', {'unit': 999, 'old': 21, 'new': 1, 'tiers': [[1, 0], [10, 5], [31, 20]], 'left': 9, 'period': 31}, [-5786, 290]), ('normal control', {'unit': 1000, 'old': 27, 'new': 21, 'tiers': [[1, 0], [8, 10], [36, 15]], 'left': 24, 'period': 31}, [-18813, 14632]), ('normal control', {'unit': 1000, 'old': 4, 'new': 9, 'tiers': [[1, 0], [6, 10], [23, 20]], 'left': 30, 'period': 31}, [-3871, 7839]), ('normal control', {'unit': 1000, 'old': 26, 'new': 40, 'tiers': [[1, 0], [5, 5], [36, 25]], 'left': 25, 'period': 31}, [-19919, 24194])]]
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 | [-15320, 27661] | [-15320, 27661] | Passed |
| regression 1 | [-13051, 806] | [-13051, 806] | Passed |
| partial-repair probe 2 | [-38646, 28424] | [-38646, 28424] | Passed |
| partial-repair probe 3 | [-38214, 16502] | [-38214, 16502] | Passed |
| normal control 4 | [-19783, 11354] | [-19783, 11354] | Passed |
| normal control 5 | [-18290, 34839] | [-18290, 34839] | Passed |
| normal control 6 | [-6619, 13626] | [-6619, 13626] | Passed |
| normal control 7 | [-32, 582] | [-32, 582] | Passed |
SHA-256 / dbf508407b7211694bc641f4a41f0c4cccf8cca9f24669abf97480e565d9ec11
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.789694+00:00.
Case digest / 49e0c69aec64850495074b8cafb92d42e655485703f2876b15bd4ca2ad799f21