broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = sum(a for a,d in zip(x["amounts"],x["due"]) if d<=x["now"])
    v1 = [min(a,max(0,x["paid"]-sum(x["amounts"][:i]))) for i,a in enumerate(x["amounts"])]
    v2 = x["paid"]>=sum(x["amounts"][:x["delivery_index"]+1])
    v3 = sum(x["amounts"]) if x["disputed"] else 0
    v4 = sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"])
    v5 = min(x["refund"],max(0,x["paid"]-x["already_refunded"]))
    v6 = [] if x["cancelled"] else [d for d in x["due"] if d>x["now"]]
    v7 = [x["now"] if x["accelerated"] and d>x["now"] else d for d in x["due"]]
    v8 = x["paid"]+(0 if x["deposit_applied"] else x["deposit"])
    v9 = max(0,x["paid"]-sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"]))
    return {'due-installments':v0,'oldest-tranche-credit':v1,'delivery-tranche-threshold':v2,'disputed-tranche-hold':v3,'waived-tranche-obligation':v4,'refundable-paid-installments':v5,'cancel-future-collection':v6,'accelerated-maturity':v7,'deposit-credit-once':v8,'excess-installment-credit':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [7, 14, 21, 28, 35]), ('independent equal receipts', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [7, 14, 21, 28, 35]), ('nothing paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 0, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [7, 14, 21, 28, 35]), ('fully paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 20, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [7, 14, 21, 28, 35]), ('first due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 2, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [7, 14, 21, 28, 35]), ('before any due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 1, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [7, 14, 21, 28, 35]), ('after all due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 8, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [7, 14, 21, 28, 35]), ('no disputes', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('no waived tranches', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [7, 14, 21, 28, 35])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['disputed-tranche-hold'], expected[N-1])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = sum(a for a,d in zip(x["amounts"],x["due"]) if d<=x["now"])
    v1 = [min(a,max(0,x["paid"]-sum(x["amounts"][:i]))) for i,a in enumerate(x["amounts"])]
    v2 = x["paid"]>=sum(x["amounts"][:x["delivery_index"]+1])
    v3 = sum(a for i,a in enumerate(x["amounts"]) if i not in x["disputed"])
    v4 = sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"])
    v5 = min(x["refund"],max(0,x["paid"]-x["already_refunded"]))
    v6 = [] if x["cancelled"] else [d for d in x["due"] if d>x["now"]]
    v7 = [x["now"] if x["accelerated"] and d>x["now"] else d for d in x["due"]]
    v8 = x["paid"]+(0 if x["deposit_applied"] else x["deposit"])
    v9 = max(0,x["paid"]-sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"]))
    return {'due-installments':v0,'oldest-tranche-credit':v1,'delivery-tranche-threshold':v2,'disputed-tranche-hold':v3,'waived-tranche-obligation':v4,'refundable-paid-installments':v5,'cancel-future-collection':v6,'accelerated-maturity':v7,'deposit-credit-once':v8,'excess-installment-credit':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [7, 14, 21, 28, 35]), ('independent equal receipts', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [7, 14, 21, 28, 35]), ('nothing paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 0, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [7, 14, 21, 28, 35]), ('fully paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 20, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [7, 14, 21, 28, 35]), ('first due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 2, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [7, 14, 21, 28, 35]), ('before any due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 1, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [7, 14, 21, 28, 35]), ('after all due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 8, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [7, 14, 21, 28, 35]), ('no disputes', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('no waived tranches', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [7, 14, 21, 28, 35])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['disputed-tranche-hold'], expected[N-1])
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)

prompt:
One disputed installment freezes the wrong proceeds.

A toy award permits staged integer-credit installments. Due amounts are a schedule; paid credits are allocated to earlier due installments first. Delivery release depends on the contractual delivery tranche and disputed tranches remain held. No interest or real payment processing is modeled. Named decision disputed-tranche-hold: For disputed tranche hold, apply the stipulated decision sum(a for i,a in enumerate(x["amounts"]) if i in x["disputed"]).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = sum(a for a,d in zip(x["amounts"],x["due"]) if d<=x["now"])
    v1 = [min(a,max(0,x["paid"]-sum(x["amounts"][:i]))) for i,a in enumerate(x["amounts"])]
    v2 = x["paid"]>=sum(x["amounts"][:x["delivery_index"]+1])
    v3 = sum(a for i,a in enumerate(x["amounts"]) if i in x["disputed"])
    v4 = sum(x["amounts"])
    v5 = min(x["refund"],max(0,x["paid"]-x["already_refunded"]))
    v6 = [] if x["cancelled"] else [d for d in x["due"] if d>x["now"]]
    v7 = [x["now"] if x["accelerated"] and d>x["now"] else d for d in x["due"]]
    v8 = x["paid"]+(0 if x["deposit_applied"] else x["deposit"])
    v9 = max(0,x["paid"]-sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"]))
    return {'due-installments':v0,'oldest-tranche-credit':v1,'delivery-tranche-threshold':v2,'disputed-tranche-hold':v3,'waived-tranche-obligation':v4,'refundable-paid-installments':v5,'cancel-future-collection':v6,'accelerated-maturity':v7,'deposit-credit-once':v8,'excess-installment-credit':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('independent equal receipts', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('nothing paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 0, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('fully paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 20, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('first due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 2, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('before any due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 1, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('after all due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 8, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('no disputes', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('no waived tranches', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [20, 40, 60, 80, 100])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['waived-tranche-obligation'], expected[N-1])
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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = sum(a for a,d in zip(x["amounts"],x["due"]) if d<=x["now"])
    v1 = [min(a,max(0,x["paid"]-sum(x["amounts"][:i]))) for i,a in enumerate(x["amounts"])]
    v2 = x["paid"]>=sum(x["amounts"][:x["delivery_index"]+1])
    v3 = sum(a for i,a in enumerate(x["amounts"]) if i in x["disputed"])
    v4 = 0 if x["waived"] else sum(x["amounts"])
    v5 = min(x["refund"],max(0,x["paid"]-x["already_refunded"]))
    v6 = [] if x["cancelled"] else [d for d in x["due"] if d>x["now"]]
    v7 = [x["now"] if x["accelerated"] and d>x["now"] else d for d in x["due"]]
    v8 = x["paid"]+(0 if x["deposit_applied"] else x["deposit"])
    v9 = max(0,x["paid"]-sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"]))
    return {'due-installments':v0,'oldest-tranche-credit':v1,'delivery-tranche-threshold':v2,'disputed-tranche-hold':v3,'waived-tranche-obligation':v4,'refundable-paid-installments':v5,'cancel-future-collection':v6,'accelerated-maturity':v7,'deposit-credit-once':v8,'excess-installment-credit':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('independent equal receipts', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('nothing paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 0, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('fully paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 20, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('first due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 2, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('before any due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 1, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('after all due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 8, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('no disputes', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [15, 30, 45, 60, 75]), ('no waived tranches', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [20, 40, 60, 80, 100])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['waived-tranche-obligation'], expected[N-1])
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)

prompt:
Waiving one award tranche waives the entire award or changes no obligation.

A toy award permits staged integer-credit installments. Due amounts are a schedule; paid credits are allocated to earlier due installments first. Delivery release depends on the contractual delivery tranche and disputed tranches remain held. No interest or real payment processing is modeled. Named decision waived-tranche-obligation: For waived tranche obligation, apply the stipulated decision sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"]).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = sum(a for a,d in zip(x["amounts"],x["due"]) if d<=x["now"])
    v1 = [min(a,max(0,x["paid"]-sum(x["amounts"][:i]))) for i,a in enumerate(x["amounts"])]
    v2 = x["paid"]>=sum(x["amounts"][:x["delivery_index"]+1])
    v3 = sum(a for i,a in enumerate(x["amounts"]) if i in x["disputed"])
    v4 = sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"])
    v5 = min(x["refund"],x["paid"])
    v6 = [] if x["cancelled"] else [d for d in x["due"] if d>x["now"]]
    v7 = [x["now"] if x["accelerated"] and d>x["now"] else d for d in x["due"]]
    v8 = x["paid"]+(0 if x["deposit_applied"] else x["deposit"])
    v9 = max(0,x["paid"]-sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"]))
    return {'due-installments':v0,'oldest-tranche-credit':v1,'delivery-tranche-threshold':v2,'disputed-tranche-hold':v3,'waived-tranche-obligation':v4,'refundable-paid-installments':v5,'cancel-future-collection':v6,'accelerated-maturity':v7,'deposit-credit-once':v8,'excess-installment-credit':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('refund overshoot', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 30, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [8, 16, 24, 32, 40]), ('independent equal receipts / refund overshoot', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 30, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [8, 16, 24, 32, 40]), ('nothing paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 0, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('normal contract', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('independent equal receipts', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('fully paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 20, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('first due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 2, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('before any due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 1, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('after all due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 8, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('no disputes', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('no waived tranches', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['refundable-paid-installments'], expected[N-1])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = sum(a for a,d in zip(x["amounts"],x["due"]) if d<=x["now"])
    v1 = [min(a,max(0,x["paid"]-sum(x["amounts"][:i]))) for i,a in enumerate(x["amounts"])]
    v2 = x["paid"]>=sum(x["amounts"][:x["delivery_index"]+1])
    v3 = sum(a for i,a in enumerate(x["amounts"]) if i in x["disputed"])
    v4 = sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"])
    v5 = x["refund"]
    v6 = [] if x["cancelled"] else [d for d in x["due"] if d>x["now"]]
    v7 = [x["now"] if x["accelerated"] and d>x["now"] else d for d in x["due"]]
    v8 = x["paid"]+(0 if x["deposit_applied"] else x["deposit"])
    v9 = max(0,x["paid"]-sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"]))
    return {'due-installments':v0,'oldest-tranche-credit':v1,'delivery-tranche-threshold':v2,'disputed-tranche-hold':v3,'waived-tranche-obligation':v4,'refundable-paid-installments':v5,'cancel-future-collection':v6,'accelerated-maturity':v7,'deposit-credit-once':v8,'excess-installment-credit':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('refund overshoot', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 30, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [8, 16, 24, 32, 40]), ('independent equal receipts / refund overshoot', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 30, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [8, 16, 24, 32, 40]), ('nothing paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 0, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('normal contract', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('independent equal receipts', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('fully paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 20, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('first due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 2, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('before any due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 1, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('after all due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 8, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('no disputes', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('no waived tranches', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['refundable-paid-installments'], expected[N-1])
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)

prompt:
Installment refunds reuse already refunded credits.

A toy award permits staged integer-credit installments. Due amounts are a schedule; paid credits are allocated to earlier due installments first. Delivery release depends on the contractual delivery tranche and disputed tranches remain held. No interest or real payment processing is modeled. Named decision refundable-paid-installments: For refundable paid installments, apply the stipulated decision min(x["refund"],max(0,x["paid"]-x["already_refunded"])).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = sum(a for a,d in zip(x["amounts"],x["due"]) if d<=x["now"])
    v1 = [min(a,max(0,x["paid"]-sum(x["amounts"][:i]))) for i,a in enumerate(x["amounts"])]
    v2 = x["paid"]>=sum(x["amounts"][:x["delivery_index"]+1])
    v3 = sum(a for i,a in enumerate(x["amounts"]) if i in x["disputed"])
    v4 = sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"])
    v5 = min(x["refund"],max(0,x["paid"]-x["already_refunded"]))
    v6 = [d for d in x["due"] if d>x["now"]]
    v7 = [x["now"] if x["accelerated"] and d>x["now"] else d for d in x["due"]]
    v8 = x["paid"]+(0 if x["deposit_applied"] else x["deposit"])
    v9 = max(0,x["paid"]-sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"]))
    return {'due-installments':v0,'oldest-tranche-credit':v1,'delivery-tranche-threshold':v2,'disputed-tranche-hold':v3,'waived-tranche-obligation':v4,'refundable-paid-installments':v5,'cancel-future-collection':v6,'accelerated-maturity':v7,'deposit-credit-once':v8,'excess-installment-credit':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('award cancelled', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': True, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[], [], [], [], []]), ('independent equal receipts / award cancelled', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': True, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [[], [], [], [], []]), ('normal contract', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[6], [12], [18], [24], [30]]), ('independent equal receipts', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [[6], [12], [18], [24], [30]]), ('nothing paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 0, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[6], [12], [18], [24], [30]]), ('fully paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 20, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[6], [12], [18], [24], [30]]), ('first due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 2, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[4, 6], [8, 12], [12, 18], [16, 24], [20, 30]]), ('before any due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 1, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('after all due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 8, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[], [], [], [], []]), ('no disputes', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[6], [12], [18], [24], [30]]), ('no waived tranches', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[6], [12], [18], [24], [30]])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['cancel-future-collection'], expected[N-1])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = sum(a for a,d in zip(x["amounts"],x["due"]) if d<=x["now"])
    v1 = [min(a,max(0,x["paid"]-sum(x["amounts"][:i]))) for i,a in enumerate(x["amounts"])]
    v2 = x["paid"]>=sum(x["amounts"][:x["delivery_index"]+1])
    v3 = sum(a for i,a in enumerate(x["amounts"]) if i in x["disputed"])
    v4 = sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"])
    v5 = min(x["refund"],max(0,x["paid"]-x["already_refunded"]))
    v6 = []
    v7 = [x["now"] if x["accelerated"] and d>x["now"] else d for d in x["due"]]
    v8 = x["paid"]+(0 if x["deposit_applied"] else x["deposit"])
    v9 = max(0,x["paid"]-sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"]))
    return {'due-installments':v0,'oldest-tranche-credit':v1,'delivery-tranche-threshold':v2,'disputed-tranche-hold':v3,'waived-tranche-obligation':v4,'refundable-paid-installments':v5,'cancel-future-collection':v6,'accelerated-maturity':v7,'deposit-credit-once':v8,'excess-installment-credit':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('award cancelled', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': True, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[], [], [], [], []]), ('independent equal receipts / award cancelled', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': True, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [[], [], [], [], []]), ('normal contract', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[6], [12], [18], [24], [30]]), ('independent equal receipts', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [[6], [12], [18], [24], [30]]), ('nothing paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 0, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[6], [12], [18], [24], [30]]), ('fully paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 20, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[6], [12], [18], [24], [30]]), ('first due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 2, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[4, 6], [8, 12], [12, 18], [16, 24], [20, 30]]), ('before any due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 1, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('after all due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 8, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[], [], [], [], []]), ('no disputes', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[6], [12], [18], [24], [30]]), ('no waived tranches', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[6], [12], [18], [24], [30]])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['cancel-future-collection'], expected[N-1])
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)

prompt:
Cancelled award installments remain scheduled for collection.

A toy award permits staged integer-credit installments. Due amounts are a schedule; paid credits are allocated to earlier due installments first. Delivery release depends on the contractual delivery tranche and disputed tranches remain held. No interest or real payment processing is modeled. Named decision cancel-future-collection: For cancel future collection, apply the stipulated decision [] if x["cancelled"] else [d for d in x["due"] if d>x["now"]].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = sum(a for a,d in zip(x["amounts"],x["due"]) if d<=x["now"])
    v1 = [min(a,max(0,x["paid"]-sum(x["amounts"][:i]))) for i,a in enumerate(x["amounts"])]
    v2 = x["paid"]>=sum(x["amounts"][:x["delivery_index"]+1])
    v3 = sum(a for i,a in enumerate(x["amounts"]) if i in x["disputed"])
    v4 = sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"])
    v5 = min(x["refund"],max(0,x["paid"]-x["already_refunded"]))
    v6 = [] if x["cancelled"] else [d for d in x["due"] if d>x["now"]]
    v7 = x["due"]
    v8 = x["paid"]+(0 if x["deposit_applied"] else x["deposit"])
    v9 = max(0,x["paid"]-sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"]))
    return {'due-installments':v0,'oldest-tranche-credit':v1,'delivery-tranche-threshold':v2,'disputed-tranche-hold':v3,'waived-tranche-obligation':v4,'refundable-paid-installments':v5,'cancel-future-collection':v6,'accelerated-maturity':v7,'deposit-credit-once':v8,'excess-installment-credit':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('accelerated maturity', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': True, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 4], [4, 8, 8], [6, 12, 12], [8, 16, 16], [10, 20, 20]]), ('independent equal receipts / accelerated maturity', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': True, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [[2, 4, 4], [4, 8, 8], [6, 12, 12], [8, 16, 16], [10, 20, 20]]), ('normal contract', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('independent equal receipts', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('nothing paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 0, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('fully paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 20, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('first due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 2, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('before any due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 1, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('after all due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 8, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('no disputes', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('no waived tranches', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['accelerated-maturity'], expected[N-1])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = sum(a for a,d in zip(x["amounts"],x["due"]) if d<=x["now"])
    v1 = [min(a,max(0,x["paid"]-sum(x["amounts"][:i]))) for i,a in enumerate(x["amounts"])]
    v2 = x["paid"]>=sum(x["amounts"][:x["delivery_index"]+1])
    v3 = sum(a for i,a in enumerate(x["amounts"]) if i in x["disputed"])
    v4 = sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"])
    v5 = min(x["refund"],max(0,x["paid"]-x["already_refunded"]))
    v6 = [] if x["cancelled"] else [d for d in x["due"] if d>x["now"]]
    v7 = [x["now"] for d in x["due"]] if x["accelerated"] else x["due"]
    v8 = x["paid"]+(0 if x["deposit_applied"] else x["deposit"])
    v9 = max(0,x["paid"]-sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"]))
    return {'due-installments':v0,'oldest-tranche-credit':v1,'delivery-tranche-threshold':v2,'disputed-tranche-hold':v3,'waived-tranche-obligation':v4,'refundable-paid-installments':v5,'cancel-future-collection':v6,'accelerated-maturity':v7,'deposit-credit-once':v8,'excess-installment-credit':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('accelerated maturity', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': True, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 4], [4, 8, 8], [6, 12, 12], [8, 16, 16], [10, 20, 20]]), ('independent equal receipts / accelerated maturity', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': True, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [[2, 4, 4], [4, 8, 8], [6, 12, 12], [8, 16, 16], [10, 20, 20]]), ('normal contract', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('independent equal receipts', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('nothing paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 0, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('fully paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 20, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('first due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 2, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('before any due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 1, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('after all due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 8, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('no disputes', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]]), ('no waived tranches', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [[2, 4, 6], [4, 8, 12], [6, 12, 18], [8, 16, 24], [10, 20, 30]])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['accelerated-maturity'], expected[N-1])
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)

prompt:
Acceleration leaves future due dates unchanged or rewrites past maturities.

A toy award permits staged integer-credit installments. Due amounts are a schedule; paid credits are allocated to earlier due installments first. Delivery release depends on the contractual delivery tranche and disputed tranches remain held. No interest or real payment processing is modeled. Named decision accelerated-maturity: For accelerated maturity, apply the stipulated decision [x["now"] if x["accelerated"] and d>x["now"] else d for d in x["due"]].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = sum(a for a,d in zip(x["amounts"],x["due"]) if d<=x["now"])
    v1 = [min(a,max(0,x["paid"]-sum(x["amounts"][:i]))) for i,a in enumerate(x["amounts"])]
    v2 = x["paid"]>=sum(x["amounts"][:x["delivery_index"]+1])
    v3 = sum(a for i,a in enumerate(x["amounts"]) if i in x["disputed"])
    v4 = sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"])
    v5 = min(x["refund"],max(0,x["paid"]-x["already_refunded"]))
    v6 = [] if x["cancelled"] else [d for d in x["due"] if d>x["now"]]
    v7 = [x["now"] if x["accelerated"] and d>x["now"] else d for d in x["due"]]
    v8 = x["paid"]+x["deposit"]
    v9 = max(0,x["paid"]-sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"]))
    return {'due-installments':v0,'oldest-tranche-credit':v1,'delivery-tranche-threshold':v2,'disputed-tranche-hold':v3,'waived-tranche-obligation':v4,'refundable-paid-installments':v5,'cancel-future-collection':v6,'accelerated-maturity':v7,'deposit-credit-once':v8,'excess-installment-credit':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('deposit already applied', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': True, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [9, 18, 27, 36, 45]), ('independent equal receipts / deposit already applied', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': True, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [9, 18, 27, 36, 45]), ('normal contract', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [13, 26, 39, 52, 65]), ('independent equal receipts', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [13, 26, 39, 52, 65]), ('nothing paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 0, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [4, 8, 12, 16, 20]), ('fully paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 20, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [24, 48, 72, 96, 120]), ('first due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 2, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [13, 26, 39, 52, 65]), ('before any due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 1, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [13, 26, 39, 52, 65]), ('after all due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 8, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [13, 26, 39, 52, 65]), ('no disputes', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [13, 26, 39, 52, 65]), ('no waived tranches', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [13, 26, 39, 52, 65])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['deposit-credit-once'], expected[N-1])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = sum(a for a,d in zip(x["amounts"],x["due"]) if d<=x["now"])
    v1 = [min(a,max(0,x["paid"]-sum(x["amounts"][:i]))) for i,a in enumerate(x["amounts"])]
    v2 = x["paid"]>=sum(x["amounts"][:x["delivery_index"]+1])
    v3 = sum(a for i,a in enumerate(x["amounts"]) if i in x["disputed"])
    v4 = sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"])
    v5 = min(x["refund"],max(0,x["paid"]-x["already_refunded"]))
    v6 = [] if x["cancelled"] else [d for d in x["due"] if d>x["now"]]
    v7 = [x["now"] if x["accelerated"] and d>x["now"] else d for d in x["due"]]
    v8 = x["paid"]
    v9 = max(0,x["paid"]-sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"]))
    return {'due-installments':v0,'oldest-tranche-credit':v1,'delivery-tranche-threshold':v2,'disputed-tranche-hold':v3,'waived-tranche-obligation':v4,'refundable-paid-installments':v5,'cancel-future-collection':v6,'accelerated-maturity':v7,'deposit-credit-once':v8,'excess-installment-credit':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('deposit already applied', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': True, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [9, 18, 27, 36, 45]), ('independent equal receipts / deposit already applied', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': True, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [9, 18, 27, 36, 45]), ('normal contract', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [13, 26, 39, 52, 65]), ('independent equal receipts', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [13, 26, 39, 52, 65]), ('nothing paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 0, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [4, 8, 12, 16, 20]), ('fully paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 20, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [24, 48, 72, 96, 120]), ('first due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 2, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [13, 26, 39, 52, 65]), ('before any due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 1, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [13, 26, 39, 52, 65]), ('after all due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 8, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [13, 26, 39, 52, 65]), ('no disputes', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [13, 26, 39, 52, 65]), ('no waived tranches', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [13, 26, 39, 52, 65])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['deposit-credit-once'], expected[N-1])
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)

prompt:
An award deposit is credited twice into installment payments.

A toy award permits staged integer-credit installments. Due amounts are a schedule; paid credits are allocated to earlier due installments first. Delivery release depends on the contractual delivery tranche and disputed tranches remain held. No interest or real payment processing is modeled. Named decision deposit-credit-once: For deposit credit once, apply the stipulated decision x["paid"]+(0 if x["deposit_applied"] else x["deposit"]).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = sum(a for a,d in zip(x["amounts"],x["due"]) if d<=x["now"])
    v1 = [min(a,max(0,x["paid"]-sum(x["amounts"][:i]))) for i,a in enumerate(x["amounts"])]
    v2 = x["paid"]>=sum(x["amounts"][:x["delivery_index"]+1])
    v3 = sum(a for i,a in enumerate(x["amounts"]) if i in x["disputed"])
    v4 = sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"])
    v5 = min(x["refund"],max(0,x["paid"]-x["already_refunded"]))
    v6 = [] if x["cancelled"] else [d for d in x["due"] if d>x["now"]]
    v7 = [x["now"] if x["accelerated"] and d>x["now"] else d for d in x["due"]]
    v8 = x["paid"]+(0 if x["deposit_applied"] else x["deposit"])
    v9 = max(0,x["paid"]-sum(x["amounts"]))
    return {'due-installments':v0,'oldest-tranche-credit':v1,'delivery-tranche-threshold':v2,'disputed-tranche-hold':v3,'waived-tranche-obligation':v4,'refundable-paid-installments':v5,'cancel-future-collection':v6,'accelerated-maturity':v7,'deposit-credit-once':v8,'excess-installment-credit':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('fully paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 20, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [5, 10, 15, 20, 25]), ('excess after waiver', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 18, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('first due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 2, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('normal contract', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('independent equal receipts', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('nothing paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 0, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('before any due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 1, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('after all due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 8, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('no disputes', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('no waived tranches', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['excess-installment-credit'], expected[N-1])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = sum(a for a,d in zip(x["amounts"],x["due"]) if d<=x["now"])
    v1 = [min(a,max(0,x["paid"]-sum(x["amounts"][:i]))) for i,a in enumerate(x["amounts"])]
    v2 = x["paid"]>=sum(x["amounts"][:x["delivery_index"]+1])
    v3 = sum(a for i,a in enumerate(x["amounts"]) if i in x["disputed"])
    v4 = sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"])
    v5 = min(x["refund"],max(0,x["paid"]-x["already_refunded"]))
    v6 = [] if x["cancelled"] else [d for d in x["due"] if d>x["now"]]
    v7 = [x["now"] if x["accelerated"] and d>x["now"] else d for d in x["due"]]
    v8 = x["paid"]+(0 if x["deposit_applied"] else x["deposit"])
    v9 = max(0,x["paid"]-sum(a for a,d in zip(x["amounts"],x["due"]) if d<=x["now"]))
    return {'due-installments':v0,'oldest-tranche-credit':v1,'delivery-tranche-threshold':v2,'disputed-tranche-hold':v3,'waived-tranche-obligation':v4,'refundable-paid-installments':v5,'cancel-future-collection':v6,'accelerated-maturity':v7,'deposit-credit-once':v8,'excess-installment-credit':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('fully paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 20, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [5, 10, 15, 20, 25]), ('excess after waiver', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 18, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [3, 6, 9, 12, 15]), ('first due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 2, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('normal contract', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('independent equal receipts', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r1', 'r2', 'r1'], 'receipt_amounts': [3, 3, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('nothing paid', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 0, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('before any due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 1, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('after all due', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 8, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('no disputes', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [], 'waived': [0], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0]), ('no waived tranches', {'amounts': [5, 7, 8], 'due': [2, 4, 6], 'now': 4, 'paid': 9, 'delivery_index': 1, 'disputed': [1], 'waived': [], 'refund': 3, 'already_refunded': 1, 'cancelled': False, 'accelerated': False, 'deposit': 4, 'deposit_applied': False, 'receipt_ids': ['r2', 'r1', 'r2'], 'receipt_amounts': [3, 2, 3], 'award_total': 20}, [0, 0, 0, 0, 0])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['excess-installment-credit'], expected[N-1])
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)

prompt:
Overpayment disposition ignores waived award tranches or refunds credits still needed for future installments.

A toy award permits staged integer-credit installments. Due amounts are a schedule; paid credits are allocated to earlier due installments first. Delivery release depends on the contractual delivery tranche and disputed tranches remain held. No interest or real payment processing is modeled. Named decision excess-installment-credit: For excess installment credit, apply the stipulated decision max(0,x["paid"]-sum(a for i,a in enumerate(x["amounts"]) if i not in x["waived"])).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = x["seller_consents"] and x["buyer_consents"]
    v1 = min(x["assign"],max(0,x["award"]-x["delivered"]))
    v2 = max(0,x["award"]-x["delivered"]-x["assign"])
    v3 = min(x["assign"],max(0,x["award"]-x["paid_units"]))
    v4 = 0 if x["novation"] and x["completed"] else x["guarantee"]
    v5 = x["assignee"] in x["approved_assignees"] and x["assignee"] not in x["banned"]
    v6 = 0 if x["assignee"]==x["original"] else x["assign"]
    v7 = [x["new_id"],x["source_id"],x["original"],x["assignee"]]
    v8 = x["new_id"]!=x["source_id"]
    v9 = x["escrow"]>=x["required_escrow"]+x["assignment_fee"]
    return {'three-party-consent':v0,'undelivered-assignment-cap':v1,'remaining-original-obligation':v2,'assigned-unpaid-units':v3,'guarantee-novation':v4,'assignee-admission':v5,'self-assignment-noop':v6,'assignment-provenance':v7,'distinct-assignment-id':v8,'escrow-and-assignment-fee':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': True, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('approved banned assignee', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': True, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['b'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('all consents / seller refuses', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': False, 'buyer_consents': True, 'assignee_accepts': True, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('all consents / buyer refuses', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': False, 'assignee_accepts': True, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('unapproved unbanned assignee', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': True, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': [], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('fee exceeds residual escrow', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': True, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 9, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('all consents', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': True, 'assignee_accepts': True, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [True, True, True, True, True]), ('seller refuses', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': False, 'buyer_consents': True, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('buyer refuses', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': False, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('overassignment', {'award': 8, 'delivered': 3, 'assign': 7, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': True, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('all delivered', {'award': 8, 'delivered': 8, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': True, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['three-party-consent'], expected[N-1])
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    v0 = x["assignee_accepts"]
    v1 = min(x["assign"],max(0,x["award"]-x["delivered"]))
    v2 = max(0,x["award"]-x["delivered"]-x["assign"])
    v3 = min(x["assign"],max(0,x["award"]-x["paid_units"]))
    v4 = 0 if x["novation"] and x["completed"] else x["guarantee"]
    v5 = x["assignee"] in x["approved_assignees"] and x["assignee"] not in x["banned"]
    v6 = 0 if x["assignee"]==x["original"] else x["assign"]
    v7 = [x["new_id"],x["source_id"],x["original"],x["assignee"]]
    v8 = x["new_id"]!=x["source_id"]
    v9 = x["escrow"]>=x["required_escrow"]+x["assignment_fee"]
    return {'three-party-consent':v0,'undelivered-assignment-cap':v1,'remaining-original-obligation':v2,'assigned-unpaid-units':v3,'guarantee-novation':v4,'assignee-admission':v5,'self-assignment-noop':v6,'assignment-provenance':v7,'distinct-assignment-id':v8,'escrow-and-assignment-fee':v9}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [('normal contract', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': True, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('approved banned assignee', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': True, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['b'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('all consents / seller refuses', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': False, 'buyer_consents': True, 'assignee_accepts': True, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('all consents / buyer refuses', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': False, 'assignee_accepts': True, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('unapproved unbanned assignee', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': True, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': [], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('fee exceeds residual escrow', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': True, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 9, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('all consents', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': True, 'assignee_accepts': True, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [True, True, True, True, True]), ('seller refuses', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': False, 'buyer_consents': True, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('buyer refuses', {'award': 8, 'delivered': 3, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': False, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('overassignment', {'award': 8, 'delivered': 3, 'assign': 7, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': True, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False]), ('all delivered', {'award': 8, 'delivered': 8, 'assign': 4, 'original': 'a', 'assignee': 'b', 'seller_consents': True, 'buyer_consents': True, 'assignee_accepts': False, 'paid_units': 2, 'guarantee': 10, 'novation': False, 'approved_assignees': ['b'], 'banned': ['c'], 'assignments': [['b', 2], ['c', 1]], 'source_id': 'w1', 'new_id': 'w2', 'completed': False, 'escrow': 12, 'required_escrow': 8, 'assignment_fee': 2}, [False, False, False, False, False])]
def vary(value):
 if type(value) is int: return value*N
 if isinstance(value,list): return [vary(v) for v in value]
 if isinstance(value,dict): return {k:(v if k in ['count', 'delivery_index', 'disputed', 'maximum_set', 'minimum_set', 'stage', 'threshold', 'waived'] else vary(v)) for k,v in value.items()}
 return value
for label, request, expected in fixtures:
 check(label, solve(vary(request))['three-party-consent'], expected[N-1])
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)

prompt:
A proposed assignee is bound without its acceptance or the transferor consents.

A winning bidder assigns an award subject to buyer, seller and assignee consents. Assignment transfers only undelivered units and the matching unpaid obligation. Partial assignments preserve original provenance and do not release an original guarantee without novation. Named decision three-party-consent: For three party consent, apply the stipulated decision x["seller_consents"] and x["buyer_consents"] and x["assignee_accepts"].

split: open-access