FAILURE MAP
← Case archive

FA-58506 / Loan amortization schedules / Open access

Payment application waterfall: held funds amount · case 01

Suspense loses its prior balance when another short payment arrives.

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

ROOT CAUSE

Only the new payment is held; prior suspense is dropped.

VERIFIED REPAIR

Hold the combined available amount.

Unsuccessful approach: Holding only prior suspense drops the new payment.

Case contract

x = {'due': {'interest', 'principal', 'late_fee', 'fees'}, 'payment', 'suspense', 'threshold', 'balance'}. Available = payment + suspense. If available < threshold, everything goes to suspense and nothing is applied. Otherwise apply in order interest, principal, late_fee, fees, then curtail principal with the remainder up to balance - applied principal; the rest is refunded. Return {'applied', 'curtailment', 'refund', 'suspense', 'new_balance'}.

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):
    avail = x['payment'] + x['suspense']
    applied = {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}
    if avail < x['threshold']:
        return {'applied': applied, 'curtailment': 0, 'refund': 0, 'suspense': x['payment'], 'new_balance': x['balance']}
    for k in ('interest', 'principal', 'late_fee', 'fees'):
        take = min(avail, x['due'][k])
        applied[k] = take
        avail -= take
    room = x['balance'] - applied['principal']
    curt = min(avail, room)
    refund = avail - curt
    return {'applied': applied, 'curtailment': curt, 'refund': refund, 'suspense': 0, 'new_balance': x['balance'] - applied['principal'] - curt}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: held funds amount', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 200, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 500, 'new_balance': 2000}], ['control 1', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 1250, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 300, 'new_balance': 800}], ['control 2', {'due': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 7200, 'suspense': 200, 'threshold': 1250, 'balance': 2000}, {'applied': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 1200, 'refund': 4000, 'suspense': 0, 'new_balance': 0}], ['control 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 0, 'suspense': 0, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 800}], ['control 4', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1250, 'suspense': 700, 'threshold': 1250, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 700, 'refund': 0, 'suspense': 0, 'new_balance': 99300}], ['control 5', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 1300, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 300, 'new_balance': 800}], ['control 6', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 700, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 500, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4500}]], [['regression: held funds amount', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 0, 'suspense': 700, 'threshold': 1250, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 700, 'new_balance': 800}], ['regression: held funds amount, partial-repair probe', {'due': {'interest': 500, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 649, 'suspense': 0, 'threshold': 650, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 649, 'new_balance': 100000}], ['control 1', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'payment': 300, 'suspense': 700, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 500, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 1500}], ['control 2', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'payment': 2500, 'suspense': 200, 'threshold': 0, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'curtailment': 165, 'refund': 0, 'suspense': 0, 'new_balance': 2835}], ['control 3', {'due': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 2500, 'suspense': 0, 'threshold': 950, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 1200, 'refund': 350, 'suspense': 0, 'new_balance': 0}], ['control 4', {'due': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 2201, 'suspense': 200, 'threshold': 1250, 'balance': 5000}, {'applied': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 201, 'refund': 0, 'suspense': 0, 'new_balance': 3999}], ['control 5', {'due': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 2500, 'suspense': 0, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 0, 'refund': 1550, 'suspense': 0, 'new_balance': 0}]], [['regression: held funds amount', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 0, 'suspense': 200, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 200, 'new_balance': 800}], ['regression: held funds amount, partial-repair probe', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 200, 'threshold': 1250, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 500, 'new_balance': 2000}], ['control 1', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 300, 'suspense': 700, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 1000, 'late_fee': 0, 'fees': 0}, 'curtailment': -200, 'refund': 200, 'suspense': 0, 'new_balance': 0}], ['control 2', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 1000, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4000}], ['control 3', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'payment': 835, 'suspense': 0, 'threshold': 835, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4200}], ['control 4', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 5800, 'suspense': 0, 'threshold': 800, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 5000, 'refund': 0, 'suspense': 0, 'new_balance': 94200}], ['control 5', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 499, 'suspense': 200, 'threshold': 500, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 199, 'refund': 0, 'suspense': 0, 'new_balance': 1801}]], [['regression: held funds amount', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'payment': 1000, 'suspense': 700, 'threshold': 2035, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 1700, 'new_balance': 2000}], ['control 1', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 36, 'suspense': 700, 'threshold': 35, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 701, 'refund': 0, 'suspense': 0, 'new_balance': 99}], ['control 2', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 1000, 'suspense': 700, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 1700, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 3300}], ['control 3', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 5800, 'suspense': 200, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 4200, 'refund': 1000, 'suspense': 0, 'new_balance': 0}], ['control 4', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 1000, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 2000}], ['control 5', {'due': {'interest': 1250, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 8250, 'suspense': 200, 'threshold': 3250, 'balance': 800}, {'applied': {'interest': 1250, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'curtailment': -1200, 'refund': 6400, 'suspense': 0, 'new_balance': 0}], ['control 6', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 200, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 500, 'principal': 700, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 100}]], [['regression: held funds amount', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 0, 'suspense': 700, 'threshold': 1250, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 700, 'new_balance': 5000}], ['regression: held funds amount, partial-repair probe', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'payment': 834, 'suspense': 0, 'threshold': 835, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 834, 'new_balance': 100000}], ['control 1', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': -1, 'suspense': 200, 'threshold': 0, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 199, 'refund': 0, 'suspense': 0, 'new_balance': 1801}], ['control 2', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 1300, 'suspense': 0, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 0}], ['control 3', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 300, 'suspense': 700, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 800, 'refund': 165, 'suspense': 0, 'new_balance': 0}], ['control 4', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 0, 'balance': 100000}, {'applied': {'interest': 300, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 100000}], ['control 5', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 1000, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 2000}]]]
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 fixtureActualExpectedOutcome
regression: held funds amount{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 2000, 'refund': 0, 'suspense': 300}{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 2000, 'refund': 0, 'suspense': 500}Failed
control 1{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300}{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300}Passed
control 2{'applied': {'fees': 0, 'interest': 1250, 'late_fee': 150, 'principal': 800}, 'curtailment': 1200, 'new_balance': 0, 'refund': 4000, 'suspense': 0}{'applied': {'fees': 0, 'interest': 1250, 'late_fee': 150, 'principal': 800}, 'curtailment': 1200, 'new_balance': 0, 'refund': 4000, 'suspense': 0}Passed
control 3{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 0}{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 0}Passed
control 4{'applied': {'fees': 0, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 700, 'new_balance': 99300, 'refund': 0, 'suspense': 0}{'applied': {'fees': 0, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 700, 'new_balance': 99300, 'refund': 0, 'suspense': 0}Passed
control 5{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300}{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300}Passed
control 6{'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 4500, 'refund': 0, 'suspense': 0}{'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 4500, 'refund': 0, 'suspense': 0}Passed

SHA-256 / 8770cc2e79512db3027b3c4634ae6b14be45c4f6b7dc24a92b6b93ab607d2b6e

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    avail = x['payment'] + x['suspense']
    applied = {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}
    if avail < x['threshold']:
        return {'applied': applied, 'curtailment': 0, 'refund': 0, 'suspense': x['suspense'], 'new_balance': x['balance']}
    for k in ('interest', 'principal', 'late_fee', 'fees'):
        take = min(avail, x['due'][k])
        applied[k] = take
        avail -= take
    room = x['balance'] - applied['principal']
    curt = min(avail, room)
    refund = avail - curt
    return {'applied': applied, 'curtailment': curt, 'refund': refund, 'suspense': 0, 'new_balance': x['balance'] - applied['principal'] - curt}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: held funds amount', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 200, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 500, 'new_balance': 2000}], ['control 1', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 1250, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 300, 'new_balance': 800}], ['control 2', {'due': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 7200, 'suspense': 200, 'threshold': 1250, 'balance': 2000}, {'applied': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 1200, 'refund': 4000, 'suspense': 0, 'new_balance': 0}], ['control 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 0, 'suspense': 0, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 800}], ['control 4', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1250, 'suspense': 700, 'threshold': 1250, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 700, 'refund': 0, 'suspense': 0, 'new_balance': 99300}], ['control 5', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 1300, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 300, 'new_balance': 800}], ['control 6', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 700, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 500, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4500}]], [['regression: held funds amount', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 0, 'suspense': 700, 'threshold': 1250, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 700, 'new_balance': 800}], ['regression: held funds amount, partial-repair probe', {'due': {'interest': 500, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 649, 'suspense': 0, 'threshold': 650, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 649, 'new_balance': 100000}], ['control 1', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'payment': 300, 'suspense': 700, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 500, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 1500}], ['control 2', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'payment': 2500, 'suspense': 200, 'threshold': 0, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'curtailment': 165, 'refund': 0, 'suspense': 0, 'new_balance': 2835}], ['control 3', {'due': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 2500, 'suspense': 0, 'threshold': 950, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 1200, 'refund': 350, 'suspense': 0, 'new_balance': 0}], ['control 4', {'due': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 2201, 'suspense': 200, 'threshold': 1250, 'balance': 5000}, {'applied': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 201, 'refund': 0, 'suspense': 0, 'new_balance': 3999}], ['control 5', {'due': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 2500, 'suspense': 0, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 0, 'refund': 1550, 'suspense': 0, 'new_balance': 0}]], [['regression: held funds amount', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 0, 'suspense': 200, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 200, 'new_balance': 800}], ['regression: held funds amount, partial-repair probe', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 200, 'threshold': 1250, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 500, 'new_balance': 2000}], ['control 1', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 300, 'suspense': 700, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 1000, 'late_fee': 0, 'fees': 0}, 'curtailment': -200, 'refund': 200, 'suspense': 0, 'new_balance': 0}], ['control 2', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 1000, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4000}], ['control 3', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'payment': 835, 'suspense': 0, 'threshold': 835, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4200}], ['control 4', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 5800, 'suspense': 0, 'threshold': 800, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 5000, 'refund': 0, 'suspense': 0, 'new_balance': 94200}], ['control 5', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 499, 'suspense': 200, 'threshold': 500, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 199, 'refund': 0, 'suspense': 0, 'new_balance': 1801}]], [['regression: held funds amount', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'payment': 1000, 'suspense': 700, 'threshold': 2035, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 1700, 'new_balance': 2000}], ['control 1', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 36, 'suspense': 700, 'threshold': 35, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 701, 'refund': 0, 'suspense': 0, 'new_balance': 99}], ['control 2', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 1000, 'suspense': 700, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 1700, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 3300}], ['control 3', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 5800, 'suspense': 200, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 4200, 'refund': 1000, 'suspense': 0, 'new_balance': 0}], ['control 4', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 1000, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 2000}], ['control 5', {'due': {'interest': 1250, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 8250, 'suspense': 200, 'threshold': 3250, 'balance': 800}, {'applied': {'interest': 1250, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'curtailment': -1200, 'refund': 6400, 'suspense': 0, 'new_balance': 0}], ['control 6', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 200, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 500, 'principal': 700, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 100}]], [['regression: held funds amount', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 0, 'suspense': 700, 'threshold': 1250, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 700, 'new_balance': 5000}], ['regression: held funds amount, partial-repair probe', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'payment': 834, 'suspense': 0, 'threshold': 835, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 834, 'new_balance': 100000}], ['control 1', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': -1, 'suspense': 200, 'threshold': 0, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 199, 'refund': 0, 'suspense': 0, 'new_balance': 1801}], ['control 2', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 1300, 'suspense': 0, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 0}], ['control 3', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 300, 'suspense': 700, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 800, 'refund': 165, 'suspense': 0, 'new_balance': 0}], ['control 4', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 0, 'balance': 100000}, {'applied': {'interest': 300, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 100000}], ['control 5', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 1000, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 2000}]]]
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 fixtureActualExpectedOutcome
regression: held funds amount{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 2000, 'refund': 0, 'suspense': 200}{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 2000, 'refund': 0, 'suspense': 500}Failed
control 1{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 0}{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300}Failed
control 2{'applied': {'fees': 0, 'interest': 1250, 'late_fee': 150, 'principal': 800}, 'curtailment': 1200, 'new_balance': 0, 'refund': 4000, 'suspense': 0}{'applied': {'fees': 0, 'interest': 1250, 'late_fee': 150, 'principal': 800}, 'curtailment': 1200, 'new_balance': 0, 'refund': 4000, 'suspense': 0}Passed
control 3{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 0}{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 0}Passed
control 4{'applied': {'fees': 0, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 700, 'new_balance': 99300, 'refund': 0, 'suspense': 0}{'applied': {'fees': 0, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 700, 'new_balance': 99300, 'refund': 0, 'suspense': 0}Passed
control 5{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 0}{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300}Failed
control 6{'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 4500, 'refund': 0, 'suspense': 0}{'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 4500, 'refund': 0, 'suspense': 0}Passed

SHA-256 / ad9b3fed4ab805580285d45067ff657e800efb242e0e1d23c7891355f6dc9af0

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    avail = x['payment'] + x['suspense']
    applied = {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}
    if avail < x['threshold']:
        return {'applied': applied, 'curtailment': 0, 'refund': 0, 'suspense': avail, 'new_balance': x['balance']}
    for k in ('interest', 'principal', 'late_fee', 'fees'):
        take = min(avail, x['due'][k])
        applied[k] = take
        avail -= take
    room = x['balance'] - applied['principal']
    curt = min(avail, room)
    refund = avail - curt
    return {'applied': applied, 'curtailment': curt, 'refund': refund, 'suspense': 0, 'new_balance': x['balance'] - applied['principal'] - curt}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: held funds amount', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 200, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 500, 'new_balance': 2000}], ['control 1', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 1250, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 300, 'new_balance': 800}], ['control 2', {'due': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 7200, 'suspense': 200, 'threshold': 1250, 'balance': 2000}, {'applied': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 1200, 'refund': 4000, 'suspense': 0, 'new_balance': 0}], ['control 3', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 0, 'suspense': 0, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 800}], ['control 4', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1250, 'suspense': 700, 'threshold': 1250, 'balance': 100000}, {'applied': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 700, 'refund': 0, 'suspense': 0, 'new_balance': 99300}], ['control 5', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 1300, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 300, 'new_balance': 800}], ['control 6', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 700, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 500, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4500}]], [['regression: held funds amount', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 0, 'suspense': 700, 'threshold': 1250, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 700, 'new_balance': 800}], ['regression: held funds amount, partial-repair probe', {'due': {'interest': 500, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 649, 'suspense': 0, 'threshold': 650, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 649, 'new_balance': 100000}], ['control 1', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'payment': 300, 'suspense': 700, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 500, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 1500}], ['control 2', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'payment': 2500, 'suspense': 200, 'threshold': 0, 'balance': 5000}, {'applied': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'curtailment': 165, 'refund': 0, 'suspense': 0, 'new_balance': 2835}], ['control 3', {'due': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 2500, 'suspense': 0, 'threshold': 950, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 1200, 'refund': 350, 'suspense': 0, 'new_balance': 0}], ['control 4', {'due': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 2201, 'suspense': 200, 'threshold': 1250, 'balance': 5000}, {'applied': {'interest': 1250, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 201, 'refund': 0, 'suspense': 0, 'new_balance': 3999}], ['control 5', {'due': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'payment': 2500, 'suspense': 0, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 150, 'fees': 0}, 'curtailment': 0, 'refund': 1550, 'suspense': 0, 'new_balance': 0}]], [['regression: held funds amount', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 0, 'suspense': 200, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 200, 'new_balance': 800}], ['regression: held funds amount, partial-repair probe', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 300, 'suspense': 200, 'threshold': 1250, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 500, 'new_balance': 2000}], ['control 1', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 300, 'suspense': 700, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 1000, 'late_fee': 0, 'fees': 0}, 'curtailment': -200, 'refund': 200, 'suspense': 0, 'new_balance': 0}], ['control 2', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 1000, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4000}], ['control 3', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'payment': 835, 'suspense': 0, 'threshold': 835, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 4200}], ['control 4', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 5800, 'suspense': 0, 'threshold': 800, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 5000, 'refund': 0, 'suspense': 0, 'new_balance': 94200}], ['control 5', {'due': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 499, 'suspense': 200, 'threshold': 500, 'balance': 2000}, {'applied': {'interest': 500, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 199, 'refund': 0, 'suspense': 0, 'new_balance': 1801}]], [['regression: held funds amount', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 0, 'fees': 35}, 'payment': 1000, 'suspense': 700, 'threshold': 2035, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 1700, 'new_balance': 2000}], ['control 1', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 36, 'suspense': 700, 'threshold': 35, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 701, 'refund': 0, 'suspense': 0, 'new_balance': 99}], ['control 2', {'due': {'interest': 0, 'principal': 2000, 'late_fee': 150, 'fees': 0}, 'payment': 1000, 'suspense': 700, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 1700, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 3300}], ['control 3', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 5800, 'suspense': 200, 'threshold': 1000, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 4200, 'refund': 1000, 'suspense': 0, 'new_balance': 0}], ['control 4', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 1000, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 2000}], ['control 5', {'due': {'interest': 1250, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 8250, 'suspense': 200, 'threshold': 3250, 'balance': 800}, {'applied': {'interest': 1250, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'curtailment': -1200, 'refund': 6400, 'suspense': 0, 'new_balance': 0}], ['control 6', {'due': {'interest': 500, 'principal': 2000, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 200, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 500, 'principal': 700, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 100}]], [['regression: held funds amount', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 0, 'suspense': 700, 'threshold': 1250, 'balance': 5000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 700, 'new_balance': 5000}], ['regression: held funds amount, partial-repair probe', {'due': {'interest': 0, 'principal': 800, 'late_fee': 0, 'fees': 35}, 'payment': 834, 'suspense': 0, 'threshold': 835, 'balance': 100000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 834, 'new_balance': 100000}], ['control 1', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': -1, 'suspense': 200, 'threshold': 0, 'balance': 2000}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 199, 'refund': 0, 'suspense': 0, 'new_balance': 1801}], ['control 2', {'due': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'payment': 1300, 'suspense': 0, 'threshold': 1000, 'balance': 800}, {'applied': {'interest': 500, 'principal': 800, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 0}], ['control 3', {'due': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'payment': 300, 'suspense': 700, 'threshold': 0, 'balance': 800}, {'applied': {'interest': 0, 'principal': 0, 'late_fee': 0, 'fees': 35}, 'curtailment': 800, 'refund': 165, 'suspense': 0, 'new_balance': 0}], ['control 4', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 150, 'fees': 0}, 'payment': 300, 'suspense': 0, 'threshold': 0, 'balance': 100000}, {'applied': {'interest': 300, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 100000}], ['control 5', {'due': {'interest': 1250, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'payment': 1000, 'suspense': 0, 'threshold': 1000, 'balance': 2000}, {'applied': {'interest': 1000, 'principal': 0, 'late_fee': 0, 'fees': 0}, 'curtailment': 0, 'refund': 0, 'suspense': 0, 'new_balance': 2000}]]]
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 fixtureActualExpectedOutcome
regression: held funds amount{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 2000, 'refund': 0, 'suspense': 500}{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 2000, 'refund': 0, 'suspense': 500}Passed
control 1{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300}{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300}Passed
control 2{'applied': {'fees': 0, 'interest': 1250, 'late_fee': 150, 'principal': 800}, 'curtailment': 1200, 'new_balance': 0, 'refund': 4000, 'suspense': 0}{'applied': {'fees': 0, 'interest': 1250, 'late_fee': 150, 'principal': 800}, 'curtailment': 1200, 'new_balance': 0, 'refund': 4000, 'suspense': 0}Passed
control 3{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 0}{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 0}Passed
control 4{'applied': {'fees': 0, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 700, 'new_balance': 99300, 'refund': 0, 'suspense': 0}{'applied': {'fees': 0, 'interest': 1250, 'late_fee': 0, 'principal': 0}, 'curtailment': 700, 'new_balance': 99300, 'refund': 0, 'suspense': 0}Passed
control 5{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300}{'applied': {'fees': 0, 'interest': 0, 'late_fee': 0, 'principal': 0}, 'curtailment': 0, 'new_balance': 800, 'refund': 0, 'suspense': 300}Passed
control 6{'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 4500, 'refund': 0, 'suspense': 0}{'applied': {'fees': 0, 'interest': 500, 'late_fee': 0, 'principal': 500}, 'curtailment': 0, 'new_balance': 4500, 'refund': 0, 'suspense': 0}Passed

SHA-256 / a90f96ba88743e631d9cfd213a1d1e9edbdca22f5ff30b49669f60893652691b

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

Case digest / de177729446e4daab4f2affa3d47852432d894bd195b479420e3b93742b5f593