FA-58696 / Loan amortization schedules / Open access
Annual escrow analysis: low point comparison · case 01
Escrow accounts with plenty of funds are told they have a shortage.
ROOT CAUSE
The difference is taken as cushion minus low point.
VERIFIED REPAIR
Compare the projected low point against the cushion.
Unsuccessful approach: Comparing against one month base ignores the configured cushion.
Case contract
x = {'disbursements': annual amounts, 'low_point': projected lowest balance, 'cushion_months', 'refund_threshold'}. total = sum; base = round_half_up(total/12); cushion = round_half_up(total*cushion_months/12); diff = low_point - cushion; shortage = max(0, -diff) is collected over 12 months rounded up; surplus = max(0, diff) is refunded when >= refund_threshold, otherwise floor(surplus/12) is credited monthly. Return {'base', 'cushion', 'shortage', 'refund', 'monthly'}.
Why this case matters
Amortization engines drive borrower statements, payoff quotes and investor remittances; a misplaced rounding step, boundary or ordering rule compounds across hundreds of periods.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
def rnd(n, d):
q, r = divmod(n, d)
return q + (1 if 2 * r >= d else 0)
total = sum(x['disbursements'])
base = rnd(total, 12)
cushion = rnd(total * x['cushion_months'], 12)
diff = cushion - x['low_point']
shortage = max(0, -diff)
surplus = max(0, diff)
refund = surplus if surplus >= x['refund_threshold'] else 0
monthly = base + (shortage + 11) // 12 - (0 if refund else surplus // 12)
return {'base': base, 'cushion': cushion, 'shortage': shortage, 'refund': refund, 'monthly': monthly}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: low point comparison', {'disbursements': [120000, 36000, 99999], 'low_point': -5000, 'cushion_months': 2, 'refund_threshold': 20000}, {'base': 21333, 'cushion': 42667, 'shortage': 47667, 'refund': 0, 'monthly': 25306}], ['control 1', {'disbursements': [36000, 7, 36000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 5000}, {'base': 6001, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 6001}], ['control 2', {'disbursements': [7, 36000, 250000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 23834, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 23834}], ['control 3', {'disbursements': [120000, 7, 7], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 5000}, {'base': 10001, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 10001}], ['control 4', {'disbursements': [120000, 120000], 'low_point': 40000, 'cushion_months': 2, 'refund_threshold': 0}, {'base': 20000, 'cushion': 40000, 'shortage': 0, 'refund': 0, 'monthly': 20000}], ['control 5', {'disbursements': [120000, 120000, 99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 28333, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 28333}], ['control 6', {'disbursements': [120000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 10000, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 10000}]], [['regression: low point comparison', {'disbursements': [120000, 36000], 'low_point': 80000, 'cushion_months': 1, 'refund_threshold': 0}, {'base': 13000, 'cushion': 13000, 'shortage': 0, 'refund': 67000, 'monthly': 13000}], ['regression: low point comparison, partial-repair probe', {'disbursements': [36000], 'low_point': 10000, 'cushion_months': 2, 'refund_threshold': 5000}, {'base': 3000, 'cushion': 6000, 'shortage': 0, 'refund': 0, 'monthly': 2667}], ['control 1', {'disbursements': [7, 36000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 3001, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 3001}], ['control 2', {'disbursements': [120000, 120000], 'low_point': 40000, 'cushion_months': 2, 'refund_threshold': 5000}, {'base': 20000, 'cushion': 40000, 'shortage': 0, 'refund': 0, 'monthly': 20000}], ['control 3', {'disbursements': [250000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 20833, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 20833}], ['control 4', {'disbursements': [250000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 5000}, {'base': 20833, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 20833}], ['control 5', {'disbursements': [7], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 1, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 1}]], [['regression: low point comparison', {'disbursements': [250000, 120000], 'low_point': 80000, 'cushion_months': 1, 'refund_threshold': 20000}, {'base': 30833, 'cushion': 30833, 'shortage': 0, 'refund': 49167, 'monthly': 30833}], ['regression: low point comparison, partial-repair probe', {'disbursements': [36000], 'low_point': 0, 'cushion_months': 5, 'refund_threshold': 5000}, {'base': 3000, 'cushion': 15000, 'shortage': 15000, 'refund': 0, 'monthly': 4250}], ['control 1', {'disbursements': [36000, 99999, 250000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 32167, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 32167}], ['control 2', {'disbursements': [120000], 'low_point': 10000, 'cushion_months': 1, 'refund_threshold': 20000}, {'base': 10000, 'cushion': 10000, 'shortage': 0, 'refund': 0, 'monthly': 10000}], ['control 3', {'disbursements': [120000, 7, 99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 18334, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 18334}], ['control 4', {'disbursements': [120000], 'low_point': 10000, 'cushion_months': 1, 'refund_threshold': 5000}, {'base': 10000, 'cushion': 10000, 'shortage': 0, 'refund': 0, 'monthly': 10000}], ['control 5', {'disbursements': [250000, 120000, 99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 39167, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 39167}]], [['regression: low point comparison', {'disbursements': [36000], 'low_point': -5000, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 3000, 'cushion': 0, 'shortage': 5000, 'refund': 0, 'monthly': 3417}], ['control 1', {'disbursements': [120000, 99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 5000}, {'base': 18333, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 18333}], ['control 2', {'disbursements': [250000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 20833, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 20833}], ['control 3', {'disbursements': [36000, 7, 120000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 13001, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 13001}], ['control 4', {'disbursements': [120000], 'low_point': 10000, 'cushion_months': 1, 'refund_threshold': 5000}, {'base': 10000, 'cushion': 10000, 'shortage': 0, 'refund': 0, 'monthly': 10000}], ['control 5', {'disbursements': [120000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 10000, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 10000}], ['control 6', {'disbursements': [99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 8333, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 8333}]], [['regression: low point comparison', {'disbursements': [120000], 'low_point': 150000, 'cushion_months': 5, 'refund_threshold': 20000}, {'base': 10000, 'cushion': 50000, 'shortage': 0, 'refund': 100000, 'monthly': 10000}], ['control 1', {'disbursements': [7, 7], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 1, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 1}], ['control 2', {'disbursements': [7, 120000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 10001, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 10001}], ['control 3', {'disbursements': [250000, 250000, 120000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 51667, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 51667}], ['control 4', {'disbursements': [99999, 120000, 99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 26667, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 26667}], ['control 5', {'disbursements': [36000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 3000, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 3000}], ['control 6', {'disbursements': [36000, 120000, 36000], 'low_point': 80000, 'cushion_months': 5, 'refund_threshold': 20000}, {'base': 16000, 'cushion': 80000, 'shortage': 0, 'refund': 0, 'monthly': 16000}]]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'raised ' + type(exc).__name__
check(label, actual, 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: low point comparison | {'base': 21333, 'cushion': 42667, 'monthly': 21333, 'refund': 47667, 'shortage': 0} | {'base': 21333, 'cushion': 42667, 'monthly': 25306, 'refund': 0, 'shortage': 47667} | Failed |
| control 1 | {'base': 6001, 'cushion': 0, 'monthly': 6001, 'refund': 0, 'shortage': 0} | {'base': 6001, 'cushion': 0, 'monthly': 6001, 'refund': 0, 'shortage': 0} | Passed |
| control 2 | {'base': 23834, 'cushion': 0, 'monthly': 23834, 'refund': 0, 'shortage': 0} | {'base': 23834, 'cushion': 0, 'monthly': 23834, 'refund': 0, 'shortage': 0} | Passed |
| control 3 | {'base': 10001, 'cushion': 0, 'monthly': 10001, 'refund': 0, 'shortage': 0} | {'base': 10001, 'cushion': 0, 'monthly': 10001, 'refund': 0, 'shortage': 0} | Passed |
| control 4 | {'base': 20000, 'cushion': 40000, 'monthly': 20000, 'refund': 0, 'shortage': 0} | {'base': 20000, 'cushion': 40000, 'monthly': 20000, 'refund': 0, 'shortage': 0} | Passed |
| control 5 | {'base': 28333, 'cushion': 0, 'monthly': 28333, 'refund': 0, 'shortage': 0} | {'base': 28333, 'cushion': 0, 'monthly': 28333, 'refund': 0, 'shortage': 0} | Passed |
| control 6 | {'base': 10000, 'cushion': 0, 'monthly': 10000, 'refund': 0, 'shortage': 0} | {'base': 10000, 'cushion': 0, 'monthly': 10000, 'refund': 0, 'shortage': 0} | Passed |
SHA-256 / 4a0ae55c3ded96ec9bad9f016206526a4559f24433abb43e9d789f8c4786f886
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
def rnd(n, d):
q, r = divmod(n, d)
return q + (1 if 2 * r >= d else 0)
total = sum(x['disbursements'])
base = rnd(total, 12)
cushion = rnd(total * x['cushion_months'], 12)
diff = x['low_point'] - base
shortage = max(0, -diff)
surplus = max(0, diff)
refund = surplus if surplus >= x['refund_threshold'] else 0
monthly = base + (shortage + 11) // 12 - (0 if refund else surplus // 12)
return {'base': base, 'cushion': cushion, 'shortage': shortage, 'refund': refund, 'monthly': monthly}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: low point comparison', {'disbursements': [120000, 36000, 99999], 'low_point': -5000, 'cushion_months': 2, 'refund_threshold': 20000}, {'base': 21333, 'cushion': 42667, 'shortage': 47667, 'refund': 0, 'monthly': 25306}], ['control 1', {'disbursements': [36000, 7, 36000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 5000}, {'base': 6001, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 6001}], ['control 2', {'disbursements': [7, 36000, 250000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 23834, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 23834}], ['control 3', {'disbursements': [120000, 7, 7], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 5000}, {'base': 10001, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 10001}], ['control 4', {'disbursements': [120000, 120000], 'low_point': 40000, 'cushion_months': 2, 'refund_threshold': 0}, {'base': 20000, 'cushion': 40000, 'shortage': 0, 'refund': 0, 'monthly': 20000}], ['control 5', {'disbursements': [120000, 120000, 99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 28333, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 28333}], ['control 6', {'disbursements': [120000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 10000, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 10000}]], [['regression: low point comparison', {'disbursements': [120000, 36000], 'low_point': 80000, 'cushion_months': 1, 'refund_threshold': 0}, {'base': 13000, 'cushion': 13000, 'shortage': 0, 'refund': 67000, 'monthly': 13000}], ['regression: low point comparison, partial-repair probe', {'disbursements': [36000], 'low_point': 10000, 'cushion_months': 2, 'refund_threshold': 5000}, {'base': 3000, 'cushion': 6000, 'shortage': 0, 'refund': 0, 'monthly': 2667}], ['control 1', {'disbursements': [7, 36000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 3001, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 3001}], ['control 2', {'disbursements': [120000, 120000], 'low_point': 40000, 'cushion_months': 2, 'refund_threshold': 5000}, {'base': 20000, 'cushion': 40000, 'shortage': 0, 'refund': 0, 'monthly': 20000}], ['control 3', {'disbursements': [250000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 20833, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 20833}], ['control 4', {'disbursements': [250000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 5000}, {'base': 20833, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 20833}], ['control 5', {'disbursements': [7], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 1, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 1}]], [['regression: low point comparison', {'disbursements': [250000, 120000], 'low_point': 80000, 'cushion_months': 1, 'refund_threshold': 20000}, {'base': 30833, 'cushion': 30833, 'shortage': 0, 'refund': 49167, 'monthly': 30833}], ['regression: low point comparison, partial-repair probe', {'disbursements': [36000], 'low_point': 0, 'cushion_months': 5, 'refund_threshold': 5000}, {'base': 3000, 'cushion': 15000, 'shortage': 15000, 'refund': 0, 'monthly': 4250}], ['control 1', {'disbursements': [36000, 99999, 250000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 32167, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 32167}], ['control 2', {'disbursements': [120000], 'low_point': 10000, 'cushion_months': 1, 'refund_threshold': 20000}, {'base': 10000, 'cushion': 10000, 'shortage': 0, 'refund': 0, 'monthly': 10000}], ['control 3', {'disbursements': [120000, 7, 99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 18334, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 18334}], ['control 4', {'disbursements': [120000], 'low_point': 10000, 'cushion_months': 1, 'refund_threshold': 5000}, {'base': 10000, 'cushion': 10000, 'shortage': 0, 'refund': 0, 'monthly': 10000}], ['control 5', {'disbursements': [250000, 120000, 99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 39167, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 39167}]], [['regression: low point comparison', {'disbursements': [36000], 'low_point': -5000, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 3000, 'cushion': 0, 'shortage': 5000, 'refund': 0, 'monthly': 3417}], ['control 1', {'disbursements': [120000, 99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 5000}, {'base': 18333, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 18333}], ['control 2', {'disbursements': [250000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 20833, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 20833}], ['control 3', {'disbursements': [36000, 7, 120000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 13001, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 13001}], ['control 4', {'disbursements': [120000], 'low_point': 10000, 'cushion_months': 1, 'refund_threshold': 5000}, {'base': 10000, 'cushion': 10000, 'shortage': 0, 'refund': 0, 'monthly': 10000}], ['control 5', {'disbursements': [120000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 10000, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 10000}], ['control 6', {'disbursements': [99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 8333, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 8333}]], [['regression: low point comparison', {'disbursements': [120000], 'low_point': 150000, 'cushion_months': 5, 'refund_threshold': 20000}, {'base': 10000, 'cushion': 50000, 'shortage': 0, 'refund': 100000, 'monthly': 10000}], ['control 1', {'disbursements': [7, 7], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 1, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 1}], ['control 2', {'disbursements': [7, 120000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 10001, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 10001}], ['control 3', {'disbursements': [250000, 250000, 120000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 51667, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 51667}], ['control 4', {'disbursements': [99999, 120000, 99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 26667, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 26667}], ['control 5', {'disbursements': [36000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 3000, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 3000}], ['control 6', {'disbursements': [36000, 120000, 36000], 'low_point': 80000, 'cushion_months': 5, 'refund_threshold': 20000}, {'base': 16000, 'cushion': 80000, 'shortage': 0, 'refund': 0, 'monthly': 16000}]]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'raised ' + type(exc).__name__
check(label, actual, 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: low point comparison | {'base': 21333, 'cushion': 42667, 'monthly': 23528, 'refund': 0, 'shortage': 26333} | {'base': 21333, 'cushion': 42667, 'monthly': 25306, 'refund': 0, 'shortage': 47667} | Failed |
| control 1 | {'base': 6001, 'cushion': 0, 'monthly': 6502, 'refund': 0, 'shortage': 6001} | {'base': 6001, 'cushion': 0, 'monthly': 6001, 'refund': 0, 'shortage': 0} | Failed |
| control 2 | {'base': 23834, 'cushion': 0, 'monthly': 25821, 'refund': 0, 'shortage': 23834} | {'base': 23834, 'cushion': 0, 'monthly': 23834, 'refund': 0, 'shortage': 0} | Failed |
| control 3 | {'base': 10001, 'cushion': 0, 'monthly': 10835, 'refund': 0, 'shortage': 10001} | {'base': 10001, 'cushion': 0, 'monthly': 10001, 'refund': 0, 'shortage': 0} | Failed |
| control 4 | {'base': 20000, 'cushion': 40000, 'monthly': 20000, 'refund': 20000, 'shortage': 0} | {'base': 20000, 'cushion': 40000, 'monthly': 20000, 'refund': 0, 'shortage': 0} | Failed |
| control 5 | {'base': 28333, 'cushion': 0, 'monthly': 30695, 'refund': 0, 'shortage': 28333} | {'base': 28333, 'cushion': 0, 'monthly': 28333, 'refund': 0, 'shortage': 0} | Failed |
| control 6 | {'base': 10000, 'cushion': 0, 'monthly': 10834, 'refund': 0, 'shortage': 10000} | {'base': 10000, 'cushion': 0, 'monthly': 10000, 'refund': 0, 'shortage': 0} | Failed |
SHA-256 / c2c63740a4cefca527667e7abf538052508cf5daa91503050a026d22d51c67ef
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
def rnd(n, d):
q, r = divmod(n, d)
return q + (1 if 2 * r >= d else 0)
total = sum(x['disbursements'])
base = rnd(total, 12)
cushion = rnd(total * x['cushion_months'], 12)
diff = x['low_point'] - cushion
shortage = max(0, -diff)
surplus = max(0, diff)
refund = surplus if surplus >= x['refund_threshold'] else 0
monthly = base + (shortage + 11) // 12 - (0 if refund else surplus // 12)
return {'base': base, 'cushion': cushion, 'shortage': shortage, 'refund': refund, 'monthly': monthly}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: low point comparison', {'disbursements': [120000, 36000, 99999], 'low_point': -5000, 'cushion_months': 2, 'refund_threshold': 20000}, {'base': 21333, 'cushion': 42667, 'shortage': 47667, 'refund': 0, 'monthly': 25306}], ['control 1', {'disbursements': [36000, 7, 36000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 5000}, {'base': 6001, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 6001}], ['control 2', {'disbursements': [7, 36000, 250000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 23834, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 23834}], ['control 3', {'disbursements': [120000, 7, 7], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 5000}, {'base': 10001, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 10001}], ['control 4', {'disbursements': [120000, 120000], 'low_point': 40000, 'cushion_months': 2, 'refund_threshold': 0}, {'base': 20000, 'cushion': 40000, 'shortage': 0, 'refund': 0, 'monthly': 20000}], ['control 5', {'disbursements': [120000, 120000, 99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 28333, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 28333}], ['control 6', {'disbursements': [120000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 10000, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 10000}]], [['regression: low point comparison', {'disbursements': [120000, 36000], 'low_point': 80000, 'cushion_months': 1, 'refund_threshold': 0}, {'base': 13000, 'cushion': 13000, 'shortage': 0, 'refund': 67000, 'monthly': 13000}], ['regression: low point comparison, partial-repair probe', {'disbursements': [36000], 'low_point': 10000, 'cushion_months': 2, 'refund_threshold': 5000}, {'base': 3000, 'cushion': 6000, 'shortage': 0, 'refund': 0, 'monthly': 2667}], ['control 1', {'disbursements': [7, 36000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 3001, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 3001}], ['control 2', {'disbursements': [120000, 120000], 'low_point': 40000, 'cushion_months': 2, 'refund_threshold': 5000}, {'base': 20000, 'cushion': 40000, 'shortage': 0, 'refund': 0, 'monthly': 20000}], ['control 3', {'disbursements': [250000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 20833, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 20833}], ['control 4', {'disbursements': [250000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 5000}, {'base': 20833, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 20833}], ['control 5', {'disbursements': [7], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 1, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 1}]], [['regression: low point comparison', {'disbursements': [250000, 120000], 'low_point': 80000, 'cushion_months': 1, 'refund_threshold': 20000}, {'base': 30833, 'cushion': 30833, 'shortage': 0, 'refund': 49167, 'monthly': 30833}], ['regression: low point comparison, partial-repair probe', {'disbursements': [36000], 'low_point': 0, 'cushion_months': 5, 'refund_threshold': 5000}, {'base': 3000, 'cushion': 15000, 'shortage': 15000, 'refund': 0, 'monthly': 4250}], ['control 1', {'disbursements': [36000, 99999, 250000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 32167, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 32167}], ['control 2', {'disbursements': [120000], 'low_point': 10000, 'cushion_months': 1, 'refund_threshold': 20000}, {'base': 10000, 'cushion': 10000, 'shortage': 0, 'refund': 0, 'monthly': 10000}], ['control 3', {'disbursements': [120000, 7, 99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 18334, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 18334}], ['control 4', {'disbursements': [120000], 'low_point': 10000, 'cushion_months': 1, 'refund_threshold': 5000}, {'base': 10000, 'cushion': 10000, 'shortage': 0, 'refund': 0, 'monthly': 10000}], ['control 5', {'disbursements': [250000, 120000, 99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 39167, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 39167}]], [['regression: low point comparison', {'disbursements': [36000], 'low_point': -5000, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 3000, 'cushion': 0, 'shortage': 5000, 'refund': 0, 'monthly': 3417}], ['control 1', {'disbursements': [120000, 99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 5000}, {'base': 18333, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 18333}], ['control 2', {'disbursements': [250000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 20833, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 20833}], ['control 3', {'disbursements': [36000, 7, 120000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 13001, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 13001}], ['control 4', {'disbursements': [120000], 'low_point': 10000, 'cushion_months': 1, 'refund_threshold': 5000}, {'base': 10000, 'cushion': 10000, 'shortage': 0, 'refund': 0, 'monthly': 10000}], ['control 5', {'disbursements': [120000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 10000, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 10000}], ['control 6', {'disbursements': [99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 20000}, {'base': 8333, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 8333}]], [['regression: low point comparison', {'disbursements': [120000], 'low_point': 150000, 'cushion_months': 5, 'refund_threshold': 20000}, {'base': 10000, 'cushion': 50000, 'shortage': 0, 'refund': 100000, 'monthly': 10000}], ['control 1', {'disbursements': [7, 7], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 1, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 1}], ['control 2', {'disbursements': [7, 120000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 10001, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 10001}], ['control 3', {'disbursements': [250000, 250000, 120000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 51667, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 51667}], ['control 4', {'disbursements': [99999, 120000, 99999], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 26667, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 26667}], ['control 5', {'disbursements': [36000], 'low_point': 0, 'cushion_months': 0, 'refund_threshold': 0}, {'base': 3000, 'cushion': 0, 'shortage': 0, 'refund': 0, 'monthly': 3000}], ['control 6', {'disbursements': [36000, 120000, 36000], 'low_point': 80000, 'cushion_months': 5, 'refund_threshold': 20000}, {'base': 16000, 'cushion': 80000, 'shortage': 0, 'refund': 0, 'monthly': 16000}]]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'raised ' + type(exc).__name__
check(label, actual, 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: low point comparison | {'base': 21333, 'cushion': 42667, 'monthly': 25306, 'refund': 0, 'shortage': 47667} | {'base': 21333, 'cushion': 42667, 'monthly': 25306, 'refund': 0, 'shortage': 47667} | Passed |
| control 1 | {'base': 6001, 'cushion': 0, 'monthly': 6001, 'refund': 0, 'shortage': 0} | {'base': 6001, 'cushion': 0, 'monthly': 6001, 'refund': 0, 'shortage': 0} | Passed |
| control 2 | {'base': 23834, 'cushion': 0, 'monthly': 23834, 'refund': 0, 'shortage': 0} | {'base': 23834, 'cushion': 0, 'monthly': 23834, 'refund': 0, 'shortage': 0} | Passed |
| control 3 | {'base': 10001, 'cushion': 0, 'monthly': 10001, 'refund': 0, 'shortage': 0} | {'base': 10001, 'cushion': 0, 'monthly': 10001, 'refund': 0, 'shortage': 0} | Passed |
| control 4 | {'base': 20000, 'cushion': 40000, 'monthly': 20000, 'refund': 0, 'shortage': 0} | {'base': 20000, 'cushion': 40000, 'monthly': 20000, 'refund': 0, 'shortage': 0} | Passed |
| control 5 | {'base': 28333, 'cushion': 0, 'monthly': 28333, 'refund': 0, 'shortage': 0} | {'base': 28333, 'cushion': 0, 'monthly': 28333, 'refund': 0, 'shortage': 0} | Passed |
| control 6 | {'base': 10000, 'cushion': 0, 'monthly': 10000, 'refund': 0, 'shortage': 0} | {'base': 10000, 'cushion': 0, 'monthly': 10000, 'refund': 0, 'shortage': 0} | Passed |
SHA-256 / cf8a476dd11a82e9cf0d1b11a849cdc9534f25a3c99e1627d51cff54913ebd79
Verification & scope
A deterministic bounded teaching model with stipulated toy lending rules stated in the contract; money is integer cents and rates are basis points; it makes no claim of conformance to any regulation, servicing standard or product. 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:29.149793+00:00.
Case digest / 10ca1496154fa1f1d7b1edd9b76c94023347234dcac6acdb90015ec7892fedf0