FAILURE MAP
← Case archive

FA-58156 / Double-entry ledger accounting / Open access

Cost pool allocation entry: leftover distribution · case 01

All rounding cents pile onto the heaviest cost center.

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

ROOT CAUSE

Leftover cents are dumped on the largest weight instead of the largest remainders.

VERIFIED REPAIR

Give one leftover cent to each of the largest remainders.

Unsuccessful approach: Dumping the leftover on the first center is still not remainder-based.

Case contract

x = {'amount': signed cents, 'weights': [[center, non-negative weight]] (some positive), 'source': account}. The pool magnitude is split across positive-weight centers by the largest remainder method: floor shares, then one extra cent to the largest remainders, ties to the earlier-listed center. A non-negative amount credits the source and debits centers; a negative amount (reversal) debits the source and credits centers, all amounts positive. Return lines [[source, side, magnitude]] + [[center, side, share]] for nonzero shares in listing order.

Why this case matters

Ledger software must keep debits equal to credits and apply normal-balance, period and cutoff rules exactly; small sign or boundary slips silently misstate financial statements.

1 / The failure

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

N = 1
observations = []
def solve(x):
    amt = x['amount']
    side_src, side_dst = ('C', 'D') if amt >= 0 else ('D', 'C')
    mag = abs(amt)
    ws = [(c, w) for c, w in x['weights'] if w > 0]
    total = sum(w for _, w in ws)
    base = [mag * w // total for _, w in ws]
    rems = [mag * w % total for _, w in ws]
    left = mag - sum(base)
    order = sorted(range(len(ws)), key=lambda i: (-rems[i], i))
    base[max(range(len(ws)), key=lambda i: ws[i][1])] += left
    lines = [[x['source'], side_src, mag]]
    for (c, w), share in zip(ws, base):
        if share:
            lines.append([c, side_dst, share])
    return lines
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: leftover distribution', {'amount': 99999, 'weights': [['it', 7], ['lab', 2], ['ops', 5]], 'source': 'pool'}, [['pool', 'C', 99999], ['it', 'D', 49999], ['lab', 'D', 14286], ['ops', 'D', 35714]]], ['control 1', {'amount': 7, 'weights': [['fin', 0], ['it', 7], ['hr', 2], ['lab', 3], ['ops', 2]], 'source': 'pool'}, [['pool', 'C', 7], ['it', 'D', 4], ['hr', 'D', 1], ['lab', 'D', 1], ['ops', 'D', 1]]], ['control 2', {'amount': 7, 'weights': [['mkt', 0], ['fin', 1]], 'source': 'pool'}, [['pool', 'C', 7], ['fin', 'D', 7]]], ['control 3', {'amount': 99999, 'weights': [['hr', 1], ['it', 0]], 'source': 'pool'}, [['pool', 'C', 99999], ['hr', 'D', 99999]]], ['control 4', {'amount': 0, 'weights': [['ops', 3], ['mkt', 7], ['fin', 3], ['lab', 5]], 'source': 'pool'}, [['pool', 'C', 0]]], ['control 5', {'amount': 100, 'weights': [['ops', 5], ['it', 5]], 'source': 'pool'}, [['pool', 'C', 100], ['ops', 'D', 50], ['it', 'D', 50]]], ['control 6', {'amount': 0, 'weights': [['ops', 5], ['hr', 5], ['mkt', 7], ['fin', 3]], 'source': 'pool'}, [['pool', 'C', 0]]]], [['regression: leftover distribution', {'amount': 7, 'weights': [['mkt', 0], ['it', 7], ['ops', 2], ['fin', 2], ['lab', 1]], 'source': 'pool'}, [['pool', 'C', 7], ['it', 'D', 4], ['ops', 'D', 1], ['fin', 'D', 1], ['lab', 'D', 1]]], ['control 1', {'amount': 0, 'weights': [['it', 3], ['lab', 1], ['mkt', 0]], 'source': 'pool'}, [['pool', 'C', 0]]], ['control 2', {'amount': 101, 'weights': [['lab', 7], ['hr', 5]], 'source': 'pool'}, [['pool', 'C', 101], ['lab', 'D', 59], ['hr', 'D', 42]]], ['control 3', {'amount': 100, 'weights': [['fin', 7], ['lab', 0]], 'source': 'pool'}, [['pool', 'C', 100], ['fin', 'D', 100]]], ['control 4', {'amount': 0, 'weights': [['mkt', 1], ['ops', 5], ['fin', 7]], 'source': 'pool'}, [['pool', 'C', 0]]], ['control 5', {'amount': -101, 'weights': [['mkt', 7], ['fin', 1], ['hr', 1]], 'source': 'pool'}, [['pool', 'D', 101], ['mkt', 'C', 79], ['fin', 'C', 11], ['hr', 'C', 11]]], ['control 6', {'amount': 3, 'weights': [['it', 0], ['hr', 0], ['fin', 2], ['ops', 2]], 'source': 'pool'}, [['pool', 'C', 3], ['fin', 'D', 2], ['ops', 'D', 1]]]], [['regression: leftover distribution', {'amount': 7, 'weights': [['it', 0], ['lab', 7], ['mkt', 1], ['hr', 3]], 'source': 'pool'}, [['pool', 'C', 7], ['lab', 'D', 4], ['mkt', 'D', 1], ['hr', 'D', 2]]], ['control 1', {'amount': 7, 'weights': [['fin', 1], ['mkt', 5]], 'source': 'pool'}, [['pool', 'C', 7], ['fin', 'D', 1], ['mkt', 'D', 6]]], ['control 2', {'amount': 3, 'weights': [['it', 7], ['hr', 1]], 'source': 'pool'}, [['pool', 'C', 3], ['it', 'D', 3]]], ['control 3', {'amount': 1000, 'weights': [['ops', 7], ['mkt', 5], ['fin', 7]], 'source': 'pool'}, [['pool', 'C', 1000], ['ops', 'D', 369], ['mkt', 'D', 263], ['fin', 'D', 368]]], ['control 4', {'amount': 0, 'weights': [['it', 7], ['ops', 7], ['lab', 5], ['hr', 7]], 'source': 'pool'}, [['pool', 'C', 0]]], ['control 5', {'amount': 7, 'weights': [['mkt', 0], ['ops', 1], ['fin', 5]], 'source': 'pool'}, [['pool', 'C', 7], ['ops', 'D', 1], ['fin', 'D', 6]]], ['control 6', {'amount': -7, 'weights': [['mkt', 7], ['fin', 7]], 'source': 'pool'}, [['pool', 'D', 7], ['mkt', 'C', 4], ['fin', 'C', 3]]]], [['regression: leftover distribution', {'amount': 100, 'weights': [['it', 7], ['fin', 3], ['mkt', 7], ['hr', 1]], 'source': 'pool'}, [['pool', 'C', 100], ['it', 'D', 39], ['fin', 'D', 17], ['mkt', 'D', 39], ['hr', 'D', 5]]], ['control 1', {'amount': -7, 'weights': [['lab', 2], ['ops', 7], ['mkt', 2]], 'source': 'pool'}, [['pool', 'D', 7], ['lab', 'C', 1], ['ops', 'C', 5], ['mkt', 'C', 1]]], ['control 2', {'amount': -101, 'weights': [['it', 5], ['ops', 7]], 'source': 'pool'}, [['pool', 'D', 101], ['it', 'C', 42], ['ops', 'C', 59]]], ['control 3', {'amount': 10, 'weights': [['ops', 1], ['mkt', 7], ['fin', 1]], 'source': 'pool'}, [['pool', 'C', 10], ['ops', 'D', 1], ['mkt', 'D', 8], ['fin', 'D', 1]]], ['control 4', {'amount': 101, 'weights': [['lab', 0], ['fin', 1], ['mkt', 1], ['it', 2]], 'source': 'pool'}, [['pool', 'C', 101], ['fin', 'D', 25], ['mkt', 'D', 25], ['it', 'D', 51]]], ['control 5', {'amount': -7, 'weights': [['hr', 0], ['fin', 7]], 'source': 'pool'}, [['pool', 'D', 7], ['fin', 'C', 7]]], ['control 6', {'amount': 3, 'weights': [['ops', 7], ['hr', 1], ['fin', 1], ['mkt', 7]], 'source': 'pool'}, [['pool', 'C', 3], ['ops', 'D', 2], ['mkt', 'D', 1]]]], [['regression: leftover distribution', {'amount': 10, 'weights': [['ops', 3], ['it', 1], ['mkt', 3], ['hr', 0]], 'source': 'pool'}, [['pool', 'C', 10], ['ops', 'D', 4], ['it', 'D', 2], ['mkt', 'D', 4]]], ['control 1', {'amount': 100, 'weights': [['fin', 2], ['hr', 0], ['it', 0], ['mkt', 0]], 'source': 'pool'}, [['pool', 'C', 100], ['fin', 'D', 100]]], ['control 2', {'amount': 7, 'weights': [['mkt', 1], ['it', 0]], 'source': 'pool'}, [['pool', 'C', 7], ['mkt', 'D', 7]]], ['control 3', {'amount': 10, 'weights': [['mkt', 1], ['it', 7], ['fin', 0], ['ops', 1]], 'source': 'pool'}, [['pool', 'C', 10], ['mkt', 'D', 1], ['it', 'D', 8], ['ops', 'D', 1]]], ['control 4', {'amount': 101, 'weights': [['fin', 2], ['hr', 2]], 'source': 'pool'}, [['pool', 'C', 101], ['fin', 'D', 51], ['hr', 'D', 50]]], ['control 5', {'amount': 10, 'weights': [['ops', 5], ['fin', 7], ['it', 0]], 'source': 'pool'}, [['pool', 'C', 10], ['ops', 'D', 4], ['fin', 'D', 6]]], ['control 6', {'amount': 7, 'weights': [['it', 0], ['lab', 3]], 'source': 'pool'}, [['pool', 'C', 7], ['lab', 'D', 7]]]]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'raised ' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: leftover distribution[['pool', 'C', 99999], ['it', 'D', 50001], ['lab', 'D', 14285], ['ops', 'D', 35713]][['pool', 'C', 99999], ['it', 'D', 49999], ['lab', 'D', 14286], ['ops', 'D', 35714]]Failed
control 1[['pool', 'C', 7], ['it', 'D', 4], ['hr', 'D', 1], ['lab', 'D', 1], ['ops', 'D', 1]][['pool', 'C', 7], ['it', 'D', 4], ['hr', 'D', 1], ['lab', 'D', 1], ['ops', 'D', 1]]Passed
control 2[['pool', 'C', 7], ['fin', 'D', 7]][['pool', 'C', 7], ['fin', 'D', 7]]Passed
control 3[['pool', 'C', 99999], ['hr', 'D', 99999]][['pool', 'C', 99999], ['hr', 'D', 99999]]Passed
control 4[['pool', 'C', 0]][['pool', 'C', 0]]Passed
control 5[['pool', 'C', 100], ['ops', 'D', 50], ['it', 'D', 50]][['pool', 'C', 100], ['ops', 'D', 50], ['it', 'D', 50]]Passed
control 6[['pool', 'C', 0]][['pool', 'C', 0]]Passed

SHA-256 / 14f5a8a968ec80b491ce2445b61e9d57bc2efc16853911d776719d4b8205512d

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    amt = x['amount']
    side_src, side_dst = ('C', 'D') if amt >= 0 else ('D', 'C')
    mag = abs(amt)
    ws = [(c, w) for c, w in x['weights'] if w > 0]
    total = sum(w for _, w in ws)
    base = [mag * w // total for _, w in ws]
    rems = [mag * w % total for _, w in ws]
    left = mag - sum(base)
    order = sorted(range(len(ws)), key=lambda i: (-rems[i], i))
    base[0] += left
    lines = [[x['source'], side_src, mag]]
    for (c, w), share in zip(ws, base):
        if share:
            lines.append([c, side_dst, share])
    return lines
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: leftover distribution', {'amount': 99999, 'weights': [['it', 7], ['lab', 2], ['ops', 5]], 'source': 'pool'}, [['pool', 'C', 99999], ['it', 'D', 49999], ['lab', 'D', 14286], ['ops', 'D', 35714]]], ['control 1', {'amount': 7, 'weights': [['fin', 0], ['it', 7], ['hr', 2], ['lab', 3], ['ops', 2]], 'source': 'pool'}, [['pool', 'C', 7], ['it', 'D', 4], ['hr', 'D', 1], ['lab', 'D', 1], ['ops', 'D', 1]]], ['control 2', {'amount': 7, 'weights': [['mkt', 0], ['fin', 1]], 'source': 'pool'}, [['pool', 'C', 7], ['fin', 'D', 7]]], ['control 3', {'amount': 99999, 'weights': [['hr', 1], ['it', 0]], 'source': 'pool'}, [['pool', 'C', 99999], ['hr', 'D', 99999]]], ['control 4', {'amount': 0, 'weights': [['ops', 3], ['mkt', 7], ['fin', 3], ['lab', 5]], 'source': 'pool'}, [['pool', 'C', 0]]], ['control 5', {'amount': 100, 'weights': [['ops', 5], ['it', 5]], 'source': 'pool'}, [['pool', 'C', 100], ['ops', 'D', 50], ['it', 'D', 50]]], ['control 6', {'amount': 0, 'weights': [['ops', 5], ['hr', 5], ['mkt', 7], ['fin', 3]], 'source': 'pool'}, [['pool', 'C', 0]]]], [['regression: leftover distribution', {'amount': 7, 'weights': [['mkt', 0], ['it', 7], ['ops', 2], ['fin', 2], ['lab', 1]], 'source': 'pool'}, [['pool', 'C', 7], ['it', 'D', 4], ['ops', 'D', 1], ['fin', 'D', 1], ['lab', 'D', 1]]], ['control 1', {'amount': 0, 'weights': [['it', 3], ['lab', 1], ['mkt', 0]], 'source': 'pool'}, [['pool', 'C', 0]]], ['control 2', {'amount': 101, 'weights': [['lab', 7], ['hr', 5]], 'source': 'pool'}, [['pool', 'C', 101], ['lab', 'D', 59], ['hr', 'D', 42]]], ['control 3', {'amount': 100, 'weights': [['fin', 7], ['lab', 0]], 'source': 'pool'}, [['pool', 'C', 100], ['fin', 'D', 100]]], ['control 4', {'amount': 0, 'weights': [['mkt', 1], ['ops', 5], ['fin', 7]], 'source': 'pool'}, [['pool', 'C', 0]]], ['control 5', {'amount': -101, 'weights': [['mkt', 7], ['fin', 1], ['hr', 1]], 'source': 'pool'}, [['pool', 'D', 101], ['mkt', 'C', 79], ['fin', 'C', 11], ['hr', 'C', 11]]], ['control 6', {'amount': 3, 'weights': [['it', 0], ['hr', 0], ['fin', 2], ['ops', 2]], 'source': 'pool'}, [['pool', 'C', 3], ['fin', 'D', 2], ['ops', 'D', 1]]]], [['regression: leftover distribution', {'amount': 7, 'weights': [['it', 0], ['lab', 7], ['mkt', 1], ['hr', 3]], 'source': 'pool'}, [['pool', 'C', 7], ['lab', 'D', 4], ['mkt', 'D', 1], ['hr', 'D', 2]]], ['control 1', {'amount': 7, 'weights': [['fin', 1], ['mkt', 5]], 'source': 'pool'}, [['pool', 'C', 7], ['fin', 'D', 1], ['mkt', 'D', 6]]], ['control 2', {'amount': 3, 'weights': [['it', 7], ['hr', 1]], 'source': 'pool'}, [['pool', 'C', 3], ['it', 'D', 3]]], ['control 3', {'amount': 1000, 'weights': [['ops', 7], ['mkt', 5], ['fin', 7]], 'source': 'pool'}, [['pool', 'C', 1000], ['ops', 'D', 369], ['mkt', 'D', 263], ['fin', 'D', 368]]], ['control 4', {'amount': 0, 'weights': [['it', 7], ['ops', 7], ['lab', 5], ['hr', 7]], 'source': 'pool'}, [['pool', 'C', 0]]], ['control 5', {'amount': 7, 'weights': [['mkt', 0], ['ops', 1], ['fin', 5]], 'source': 'pool'}, [['pool', 'C', 7], ['ops', 'D', 1], ['fin', 'D', 6]]], ['control 6', {'amount': -7, 'weights': [['mkt', 7], ['fin', 7]], 'source': 'pool'}, [['pool', 'D', 7], ['mkt', 'C', 4], ['fin', 'C', 3]]]], [['regression: leftover distribution', {'amount': 100, 'weights': [['it', 7], ['fin', 3], ['mkt', 7], ['hr', 1]], 'source': 'pool'}, [['pool', 'C', 100], ['it', 'D', 39], ['fin', 'D', 17], ['mkt', 'D', 39], ['hr', 'D', 5]]], ['control 1', {'amount': -7, 'weights': [['lab', 2], ['ops', 7], ['mkt', 2]], 'source': 'pool'}, [['pool', 'D', 7], ['lab', 'C', 1], ['ops', 'C', 5], ['mkt', 'C', 1]]], ['control 2', {'amount': -101, 'weights': [['it', 5], ['ops', 7]], 'source': 'pool'}, [['pool', 'D', 101], ['it', 'C', 42], ['ops', 'C', 59]]], ['control 3', {'amount': 10, 'weights': [['ops', 1], ['mkt', 7], ['fin', 1]], 'source': 'pool'}, [['pool', 'C', 10], ['ops', 'D', 1], ['mkt', 'D', 8], ['fin', 'D', 1]]], ['control 4', {'amount': 101, 'weights': [['lab', 0], ['fin', 1], ['mkt', 1], ['it', 2]], 'source': 'pool'}, [['pool', 'C', 101], ['fin', 'D', 25], ['mkt', 'D', 25], ['it', 'D', 51]]], ['control 5', {'amount': -7, 'weights': [['hr', 0], ['fin', 7]], 'source': 'pool'}, [['pool', 'D', 7], ['fin', 'C', 7]]], ['control 6', {'amount': 3, 'weights': [['ops', 7], ['hr', 1], ['fin', 1], ['mkt', 7]], 'source': 'pool'}, [['pool', 'C', 3], ['ops', 'D', 2], ['mkt', 'D', 1]]]], [['regression: leftover distribution', {'amount': 10, 'weights': [['ops', 3], ['it', 1], ['mkt', 3], ['hr', 0]], 'source': 'pool'}, [['pool', 'C', 10], ['ops', 'D', 4], ['it', 'D', 2], ['mkt', 'D', 4]]], ['control 1', {'amount': 100, 'weights': [['fin', 2], ['hr', 0], ['it', 0], ['mkt', 0]], 'source': 'pool'}, [['pool', 'C', 100], ['fin', 'D', 100]]], ['control 2', {'amount': 7, 'weights': [['mkt', 1], ['it', 0]], 'source': 'pool'}, [['pool', 'C', 7], ['mkt', 'D', 7]]], ['control 3', {'amount': 10, 'weights': [['mkt', 1], ['it', 7], ['fin', 0], ['ops', 1]], 'source': 'pool'}, [['pool', 'C', 10], ['mkt', 'D', 1], ['it', 'D', 8], ['ops', 'D', 1]]], ['control 4', {'amount': 101, 'weights': [['fin', 2], ['hr', 2]], 'source': 'pool'}, [['pool', 'C', 101], ['fin', 'D', 51], ['hr', 'D', 50]]], ['control 5', {'amount': 10, 'weights': [['ops', 5], ['fin', 7], ['it', 0]], 'source': 'pool'}, [['pool', 'C', 10], ['ops', 'D', 4], ['fin', 'D', 6]]], ['control 6', {'amount': 7, 'weights': [['it', 0], ['lab', 3]], 'source': 'pool'}, [['pool', 'C', 7], ['lab', 'D', 7]]]]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'raised ' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: leftover distribution[['pool', 'C', 99999], ['it', 'D', 50001], ['lab', 'D', 14285], ['ops', 'D', 35713]][['pool', 'C', 99999], ['it', 'D', 49999], ['lab', 'D', 14286], ['ops', 'D', 35714]]Failed
control 1[['pool', 'C', 7], ['it', 'D', 4], ['hr', 'D', 1], ['lab', 'D', 1], ['ops', 'D', 1]][['pool', 'C', 7], ['it', 'D', 4], ['hr', 'D', 1], ['lab', 'D', 1], ['ops', 'D', 1]]Passed
control 2[['pool', 'C', 7], ['fin', 'D', 7]][['pool', 'C', 7], ['fin', 'D', 7]]Passed
control 3[['pool', 'C', 99999], ['hr', 'D', 99999]][['pool', 'C', 99999], ['hr', 'D', 99999]]Passed
control 4[['pool', 'C', 0]][['pool', 'C', 0]]Passed
control 5[['pool', 'C', 100], ['ops', 'D', 50], ['it', 'D', 50]][['pool', 'C', 100], ['ops', 'D', 50], ['it', 'D', 50]]Passed
control 6[['pool', 'C', 0]][['pool', 'C', 0]]Passed

SHA-256 / 17a60f0ebadf5eb413d14f399fbb0e8be0659664757a2d261fd552b2efedbb18

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    amt = x['amount']
    side_src, side_dst = ('C', 'D') if amt >= 0 else ('D', 'C')
    mag = abs(amt)
    ws = [(c, w) for c, w in x['weights'] if w > 0]
    total = sum(w for _, w in ws)
    base = [mag * w // total for _, w in ws]
    rems = [mag * w % total for _, w in ws]
    left = mag - sum(base)
    order = sorted(range(len(ws)), key=lambda i: (-rems[i], i))
    for i in order[:left]:
        base[i] += 1
    lines = [[x['source'], side_src, mag]]
    for (c, w), share in zip(ws, base):
        if share:
            lines.append([c, side_dst, share])
    return lines
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: leftover distribution', {'amount': 99999, 'weights': [['it', 7], ['lab', 2], ['ops', 5]], 'source': 'pool'}, [['pool', 'C', 99999], ['it', 'D', 49999], ['lab', 'D', 14286], ['ops', 'D', 35714]]], ['control 1', {'amount': 7, 'weights': [['fin', 0], ['it', 7], ['hr', 2], ['lab', 3], ['ops', 2]], 'source': 'pool'}, [['pool', 'C', 7], ['it', 'D', 4], ['hr', 'D', 1], ['lab', 'D', 1], ['ops', 'D', 1]]], ['control 2', {'amount': 7, 'weights': [['mkt', 0], ['fin', 1]], 'source': 'pool'}, [['pool', 'C', 7], ['fin', 'D', 7]]], ['control 3', {'amount': 99999, 'weights': [['hr', 1], ['it', 0]], 'source': 'pool'}, [['pool', 'C', 99999], ['hr', 'D', 99999]]], ['control 4', {'amount': 0, 'weights': [['ops', 3], ['mkt', 7], ['fin', 3], ['lab', 5]], 'source': 'pool'}, [['pool', 'C', 0]]], ['control 5', {'amount': 100, 'weights': [['ops', 5], ['it', 5]], 'source': 'pool'}, [['pool', 'C', 100], ['ops', 'D', 50], ['it', 'D', 50]]], ['control 6', {'amount': 0, 'weights': [['ops', 5], ['hr', 5], ['mkt', 7], ['fin', 3]], 'source': 'pool'}, [['pool', 'C', 0]]]], [['regression: leftover distribution', {'amount': 7, 'weights': [['mkt', 0], ['it', 7], ['ops', 2], ['fin', 2], ['lab', 1]], 'source': 'pool'}, [['pool', 'C', 7], ['it', 'D', 4], ['ops', 'D', 1], ['fin', 'D', 1], ['lab', 'D', 1]]], ['control 1', {'amount': 0, 'weights': [['it', 3], ['lab', 1], ['mkt', 0]], 'source': 'pool'}, [['pool', 'C', 0]]], ['control 2', {'amount': 101, 'weights': [['lab', 7], ['hr', 5]], 'source': 'pool'}, [['pool', 'C', 101], ['lab', 'D', 59], ['hr', 'D', 42]]], ['control 3', {'amount': 100, 'weights': [['fin', 7], ['lab', 0]], 'source': 'pool'}, [['pool', 'C', 100], ['fin', 'D', 100]]], ['control 4', {'amount': 0, 'weights': [['mkt', 1], ['ops', 5], ['fin', 7]], 'source': 'pool'}, [['pool', 'C', 0]]], ['control 5', {'amount': -101, 'weights': [['mkt', 7], ['fin', 1], ['hr', 1]], 'source': 'pool'}, [['pool', 'D', 101], ['mkt', 'C', 79], ['fin', 'C', 11], ['hr', 'C', 11]]], ['control 6', {'amount': 3, 'weights': [['it', 0], ['hr', 0], ['fin', 2], ['ops', 2]], 'source': 'pool'}, [['pool', 'C', 3], ['fin', 'D', 2], ['ops', 'D', 1]]]], [['regression: leftover distribution', {'amount': 7, 'weights': [['it', 0], ['lab', 7], ['mkt', 1], ['hr', 3]], 'source': 'pool'}, [['pool', 'C', 7], ['lab', 'D', 4], ['mkt', 'D', 1], ['hr', 'D', 2]]], ['control 1', {'amount': 7, 'weights': [['fin', 1], ['mkt', 5]], 'source': 'pool'}, [['pool', 'C', 7], ['fin', 'D', 1], ['mkt', 'D', 6]]], ['control 2', {'amount': 3, 'weights': [['it', 7], ['hr', 1]], 'source': 'pool'}, [['pool', 'C', 3], ['it', 'D', 3]]], ['control 3', {'amount': 1000, 'weights': [['ops', 7], ['mkt', 5], ['fin', 7]], 'source': 'pool'}, [['pool', 'C', 1000], ['ops', 'D', 369], ['mkt', 'D', 263], ['fin', 'D', 368]]], ['control 4', {'amount': 0, 'weights': [['it', 7], ['ops', 7], ['lab', 5], ['hr', 7]], 'source': 'pool'}, [['pool', 'C', 0]]], ['control 5', {'amount': 7, 'weights': [['mkt', 0], ['ops', 1], ['fin', 5]], 'source': 'pool'}, [['pool', 'C', 7], ['ops', 'D', 1], ['fin', 'D', 6]]], ['control 6', {'amount': -7, 'weights': [['mkt', 7], ['fin', 7]], 'source': 'pool'}, [['pool', 'D', 7], ['mkt', 'C', 4], ['fin', 'C', 3]]]], [['regression: leftover distribution', {'amount': 100, 'weights': [['it', 7], ['fin', 3], ['mkt', 7], ['hr', 1]], 'source': 'pool'}, [['pool', 'C', 100], ['it', 'D', 39], ['fin', 'D', 17], ['mkt', 'D', 39], ['hr', 'D', 5]]], ['control 1', {'amount': -7, 'weights': [['lab', 2], ['ops', 7], ['mkt', 2]], 'source': 'pool'}, [['pool', 'D', 7], ['lab', 'C', 1], ['ops', 'C', 5], ['mkt', 'C', 1]]], ['control 2', {'amount': -101, 'weights': [['it', 5], ['ops', 7]], 'source': 'pool'}, [['pool', 'D', 101], ['it', 'C', 42], ['ops', 'C', 59]]], ['control 3', {'amount': 10, 'weights': [['ops', 1], ['mkt', 7], ['fin', 1]], 'source': 'pool'}, [['pool', 'C', 10], ['ops', 'D', 1], ['mkt', 'D', 8], ['fin', 'D', 1]]], ['control 4', {'amount': 101, 'weights': [['lab', 0], ['fin', 1], ['mkt', 1], ['it', 2]], 'source': 'pool'}, [['pool', 'C', 101], ['fin', 'D', 25], ['mkt', 'D', 25], ['it', 'D', 51]]], ['control 5', {'amount': -7, 'weights': [['hr', 0], ['fin', 7]], 'source': 'pool'}, [['pool', 'D', 7], ['fin', 'C', 7]]], ['control 6', {'amount': 3, 'weights': [['ops', 7], ['hr', 1], ['fin', 1], ['mkt', 7]], 'source': 'pool'}, [['pool', 'C', 3], ['ops', 'D', 2], ['mkt', 'D', 1]]]], [['regression: leftover distribution', {'amount': 10, 'weights': [['ops', 3], ['it', 1], ['mkt', 3], ['hr', 0]], 'source': 'pool'}, [['pool', 'C', 10], ['ops', 'D', 4], ['it', 'D', 2], ['mkt', 'D', 4]]], ['control 1', {'amount': 100, 'weights': [['fin', 2], ['hr', 0], ['it', 0], ['mkt', 0]], 'source': 'pool'}, [['pool', 'C', 100], ['fin', 'D', 100]]], ['control 2', {'amount': 7, 'weights': [['mkt', 1], ['it', 0]], 'source': 'pool'}, [['pool', 'C', 7], ['mkt', 'D', 7]]], ['control 3', {'amount': 10, 'weights': [['mkt', 1], ['it', 7], ['fin', 0], ['ops', 1]], 'source': 'pool'}, [['pool', 'C', 10], ['mkt', 'D', 1], ['it', 'D', 8], ['ops', 'D', 1]]], ['control 4', {'amount': 101, 'weights': [['fin', 2], ['hr', 2]], 'source': 'pool'}, [['pool', 'C', 101], ['fin', 'D', 51], ['hr', 'D', 50]]], ['control 5', {'amount': 10, 'weights': [['ops', 5], ['fin', 7], ['it', 0]], 'source': 'pool'}, [['pool', 'C', 10], ['ops', 'D', 4], ['fin', 'D', 6]]], ['control 6', {'amount': 7, 'weights': [['it', 0], ['lab', 3]], 'source': 'pool'}, [['pool', 'C', 7], ['lab', 'D', 7]]]]]
for label, args, expected in fixtures[N-1]:
    try:
        actual = solve(args)
    except Exception as exc:
        actual = 'raised ' + type(exc).__name__
    check(label, actual, expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: leftover distribution[['pool', 'C', 99999], ['it', 'D', 49999], ['lab', 'D', 14286], ['ops', 'D', 35714]][['pool', 'C', 99999], ['it', 'D', 49999], ['lab', 'D', 14286], ['ops', 'D', 35714]]Passed
control 1[['pool', 'C', 7], ['it', 'D', 4], ['hr', 'D', 1], ['lab', 'D', 1], ['ops', 'D', 1]][['pool', 'C', 7], ['it', 'D', 4], ['hr', 'D', 1], ['lab', 'D', 1], ['ops', 'D', 1]]Passed
control 2[['pool', 'C', 7], ['fin', 'D', 7]][['pool', 'C', 7], ['fin', 'D', 7]]Passed
control 3[['pool', 'C', 99999], ['hr', 'D', 99999]][['pool', 'C', 99999], ['hr', 'D', 99999]]Passed
control 4[['pool', 'C', 0]][['pool', 'C', 0]]Passed
control 5[['pool', 'C', 100], ['ops', 'D', 50], ['it', 'D', 50]][['pool', 'C', 100], ['ops', 'D', 50], ['it', 'D', 50]]Passed
control 6[['pool', 'C', 0]][['pool', 'C', 0]]Passed

SHA-256 / a4738e24b6e631298b3cbcd4047b0babc982d5c8599bbca8b8befbd5f6abbb9e

Verification & scope

A deterministic bounded teaching model with stipulated toy bookkeeping rules stated in the contract; amounts are integer cents; it makes no claim of conformance to any accounting standard or product. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

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

Case digest / a610e67d156af24ffbaf207839f3816a27aec427a5f7636c3ebb03d71c8b7cc6