FAILURE MAP
← Case archive

FA-60266 / Inventory cost layering / Open access

Production lot cost roll-up with yield: abnormal loss floor · case 01

A lot that beats its normal yield books a negative abnormal loss that lowers good-unit cost below cost.

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

ROOT CAUSE

Abnormal units are scrap minus normal loss without a zero floor.

VERIFIED REPAIR

Abnormal units = max(0, scrap - normal).

Unsuccessful approach: Taking the absolute difference turns better-than-normal yield into an abnormal loss.

Case contract

Input {material:[[qty,unit]], hours, rate, oh_bp (of labor cost), input_units, good_units, recovery (per scrapped unit), normal_bp}. Total = material + labor + overhead. Scrap = input - good; normal loss = floor(input*normal_bp/10000); abnormal = max(0, scrap - normal) valued at floor(total/input) per unit and expensed. Scrap recovery credits every scrapped unit. Good-unit cost = round-half-up((total - recovery credit - abnormal value)/good); good_units == 0 returns {"error"}. Return {total, abnormal_units, abnormal_value, unit_cost}.

Why this case matters

Inventory valuation and cost-of-goods decisions depend on this rule.

1 / The failure

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

N = 1
observations = []
def solve(x):
    mat = sum(q * u for q, u in x['material'])
    labor = x['hours'] * x['rate']
    oh = labor * x['oh_bp'] // 10000
    total = mat + labor + oh
    if x['good_units'] == 0:
        return {'error': 'no good output'}
    scrap = x['input_units'] - x['good_units']
    normal = x['input_units'] * x['normal_bp'] // 10000
    abnormal = scrap - normal
    ab_value = abnormal * (total // x['input_units'])
    credit = scrap * x['recovery']
    net = total - credit - ab_value
    unit = (2 * net + x['good_units']) // (2 * x['good_units'])
    return {'total': total, 'abnormal_units': abnormal, 'abnormal_value': ab_value, 'unit_cost': unit}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 501}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 39, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 9, 'abnormal_value': 1980, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2010, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6020, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 151}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 4, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 26037, 'abnormal_units': 3, 'abnormal_value': 2601, 'unit_cost': 866}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 151, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 502}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 38, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 10, 'abnormal_value': 2200, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2020, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6040, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 151}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 5, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 31797, 'abnormal_units': 3, 'abnormal_value': 3177, 'unit_cost': 1058}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 152, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 503}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 37, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 11, 'abnormal_value': 2420, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2030, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6060, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 152}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 6, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 37557, 'abnormal_units': 3, 'abnormal_value': 3753, 'unit_cost': 1250}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 153, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 504}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 36, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 12, 'abnormal_value': 2640, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2040, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6080, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 152}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 7, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 43317, 'abnormal_units': 3, 'abnormal_value': 4329, 'unit_cost': 1442}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 154, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 505}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 35, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 13, 'abnormal_value': 2860, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2050, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6100, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 153}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 8, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 49077, 'abnormal_units': 3, 'abnormal_value': 4905, 'unit_cost': 1634}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 155, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
normal run{'abnormal_units': -1, 'abnormal_value': -286, 'total': 28600, 'unit_cost': 301}{'abnormal_units': 0, 'abnormal_value': 0, 'total': 28600, 'unit_cost': 298}Failed
abnormal loss{'abnormal_units': 9, 'abnormal_value': 1980, 'total': 11000, 'unit_cost': 228}{'abnormal_units': 9, 'abnormal_value': 1980, 'total': 11000, 'unit_cost': 228}Passed
better than normal{'abnormal_units': -4, 'abnormal_value': -600, 'total': 6020, 'unit_cost': 166}{'abnormal_units': 0, 'abnormal_value': 0, 'total': 6020, 'unit_cost': 151}Failed
no good units{'error': 'no good output'}{'error': 'no good output'}Passed
high overhead{'abnormal_units': 3, 'abnormal_value': 2601, 'total': 26037, 'unit_cost': 866}{'abnormal_units': 3, 'abnormal_value': 2601, 'total': 26037, 'unit_cost': 866}Passed
recovery heavy{'abnormal_units': 3, 'abnormal_value': 945, 'total': 18900, 'unit_cost': 325}{'abnormal_units': 3, 'abnormal_value': 945, 'total': 18900, 'unit_cost': 325}Passed

SHA-256 / 3a1434694774e6b096cfe42f5e0f049cfab822e64440a95dbdcf9c769e567139

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    mat = sum(q * u for q, u in x['material'])
    labor = x['hours'] * x['rate']
    oh = labor * x['oh_bp'] // 10000
    total = mat + labor + oh
    if x['good_units'] == 0:
        return {'error': 'no good output'}
    scrap = x['input_units'] - x['good_units']
    normal = x['input_units'] * x['normal_bp'] // 10000
    abnormal = abs(scrap - normal)
    ab_value = abnormal * (total // x['input_units'])
    credit = scrap * x['recovery']
    net = total - credit - ab_value
    unit = (2 * net + x['good_units']) // (2 * x['good_units'])
    return {'total': total, 'abnormal_units': abnormal, 'abnormal_value': ab_value, 'unit_cost': unit}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 501}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 39, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 9, 'abnormal_value': 1980, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2010, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6020, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 151}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 4, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 26037, 'abnormal_units': 3, 'abnormal_value': 2601, 'unit_cost': 866}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 151, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 502}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 38, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 10, 'abnormal_value': 2200, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2020, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6040, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 151}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 5, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 31797, 'abnormal_units': 3, 'abnormal_value': 3177, 'unit_cost': 1058}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 152, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 503}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 37, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 11, 'abnormal_value': 2420, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2030, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6060, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 152}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 6, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 37557, 'abnormal_units': 3, 'abnormal_value': 3753, 'unit_cost': 1250}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 153, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 504}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 36, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 12, 'abnormal_value': 2640, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2040, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6080, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 152}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 7, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 43317, 'abnormal_units': 3, 'abnormal_value': 4329, 'unit_cost': 1442}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 154, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 505}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 35, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 13, 'abnormal_value': 2860, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2050, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6100, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 153}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 8, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 49077, 'abnormal_units': 3, 'abnormal_value': 4905, 'unit_cost': 1634}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 155, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
normal run{'abnormal_units': 1, 'abnormal_value': 286, 'total': 28600, 'unit_cost': 295}{'abnormal_units': 0, 'abnormal_value': 0, 'total': 28600, 'unit_cost': 298}Failed
abnormal loss{'abnormal_units': 9, 'abnormal_value': 1980, 'total': 11000, 'unit_cost': 228}{'abnormal_units': 9, 'abnormal_value': 1980, 'total': 11000, 'unit_cost': 228}Passed
better than normal{'abnormal_units': 4, 'abnormal_value': 600, 'total': 6020, 'unit_cost': 136}{'abnormal_units': 0, 'abnormal_value': 0, 'total': 6020, 'unit_cost': 151}Failed
no good units{'error': 'no good output'}{'error': 'no good output'}Passed
high overhead{'abnormal_units': 3, 'abnormal_value': 2601, 'total': 26037, 'unit_cost': 866}{'abnormal_units': 3, 'abnormal_value': 2601, 'total': 26037, 'unit_cost': 866}Passed
recovery heavy{'abnormal_units': 3, 'abnormal_value': 945, 'total': 18900, 'unit_cost': 325}{'abnormal_units': 3, 'abnormal_value': 945, 'total': 18900, 'unit_cost': 325}Passed

SHA-256 / e177090e6f5dd8a1725c44c676db33d351c87241d50d5678888abb9e642c1c72

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    mat = sum(q * u for q, u in x['material'])
    labor = x['hours'] * x['rate']
    oh = labor * x['oh_bp'] // 10000
    total = mat + labor + oh
    if x['good_units'] == 0:
        return {'error': 'no good output'}
    scrap = x['input_units'] - x['good_units']
    normal = x['input_units'] * x['normal_bp'] // 10000
    abnormal = max(0, scrap - normal)
    ab_value = abnormal * (total // x['input_units'])
    credit = scrap * x['recovery']
    net = total - credit - ab_value
    unit = (2 * net + x['good_units']) // (2 * x['good_units'])
    return {'total': total, 'abnormal_units': abnormal, 'abnormal_value': ab_value, 'unit_cost': unit}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 501}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 39, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 9, 'abnormal_value': 1980, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2010, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6020, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 151}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 4, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 26037, 'abnormal_units': 3, 'abnormal_value': 2601, 'unit_cost': 866}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 151, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 502}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 38, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 10, 'abnormal_value': 2200, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2020, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6040, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 151}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 5, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 31797, 'abnormal_units': 3, 'abnormal_value': 3177, 'unit_cost': 1058}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 152, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 503}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 37, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 11, 'abnormal_value': 2420, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2030, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6060, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 152}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 6, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 37557, 'abnormal_units': 3, 'abnormal_value': 3753, 'unit_cost': 1250}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 153, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 504}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 36, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 12, 'abnormal_value': 2640, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2040, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6080, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 152}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 7, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 43317, 'abnormal_units': 3, 'abnormal_value': 4329, 'unit_cost': 1442}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 154, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]], [['normal run', {'material': [[10, 300], [5, 120]], 'hours': 4, 'rate': 2500, 'oh_bp': 15000, 'input_units': 100, 'good_units': 96, 'recovery': 5, 'normal_bp': 505}, {'total': 28600, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 298}], ['abnormal loss', {'material': [[20, 100]], 'hours': 2, 'rate': 3000, 'oh_bp': 5000, 'input_units': 50, 'good_units': 35, 'recovery': 10, 'normal_bp': 400}, {'total': 11000, 'abnormal_units': 13, 'abnormal_value': 2860, 'unit_cost': 228}], ['better than normal', {'material': [[8, 250]], 'hours': 1, 'rate': 2050, 'oh_bp': 10000, 'input_units': 40, 'good_units': 40, 'recovery': 0, 'normal_bp': 1000}, {'total': 6100, 'abnormal_units': 0, 'abnormal_value': 0, 'unit_cost': 153}], ['no good units', {'material': [[1, 100]], 'hours': 1, 'rate': 100, 'oh_bp': 0, 'input_units': 5, 'good_units': 0, 'recovery': 1, 'normal_bp': 0}, {'error': 'no good output'}], ['high overhead', {'material': [[3, 999]], 'hours': 8, 'rate': 1800, 'oh_bp': 22000, 'input_units': 30, 'good_units': 27, 'recovery': 20, 'normal_bp': 300}, {'total': 49077, 'abnormal_units': 3, 'abnormal_value': 4905, 'unit_cost': 1634}], ['recovery heavy', {'material': [[12, 450]], 'hours': 5, 'rate': 1500, 'oh_bp': 8000, 'input_units': 60, 'good_units': 51, 'recovery': 155, 'normal_bp': 1000}, {'total': 18900, 'abnormal_units': 3, 'abnormal_value': 945, 'unit_cost': 325}]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
normal run{'abnormal_units': 0, 'abnormal_value': 0, 'total': 28600, 'unit_cost': 298}{'abnormal_units': 0, 'abnormal_value': 0, 'total': 28600, 'unit_cost': 298}Passed
abnormal loss{'abnormal_units': 9, 'abnormal_value': 1980, 'total': 11000, 'unit_cost': 228}{'abnormal_units': 9, 'abnormal_value': 1980, 'total': 11000, 'unit_cost': 228}Passed
better than normal{'abnormal_units': 0, 'abnormal_value': 0, 'total': 6020, 'unit_cost': 151}{'abnormal_units': 0, 'abnormal_value': 0, 'total': 6020, 'unit_cost': 151}Passed
no good units{'error': 'no good output'}{'error': 'no good output'}Passed
high overhead{'abnormal_units': 3, 'abnormal_value': 2601, 'total': 26037, 'unit_cost': 866}{'abnormal_units': 3, 'abnormal_value': 2601, 'total': 26037, 'unit_cost': 866}Passed
recovery heavy{'abnormal_units': 3, 'abnormal_value': 945, 'total': 18900, 'unit_cost': 325}{'abnormal_units': 3, 'abnormal_value': 945, 'total': 18900, 'unit_cost': 325}Passed

SHA-256 / b37fa334cbdc369b425e57129b69dd5f376bc747ff07b662935950fbc6958d92

Verification & scope

Stipulated bounded teaching model with explicit toy rules; not an accounting-standard implementation. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:46:44.070657+00:00.

Case digest / ff090cefc720431f339b7eb7f25d5e5cfd7bd0171a72f9c86b0ae8551a6b6897