FAILURE MAP
← Case archive

FA-59371 / Subscription proration billing / Open access

Second-granular proration line items: change at period end · case 01

A change exactly at renewal emits zero-amount proration lines.

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

ROOT CAUSE

Changes at the period end are treated as inside the period.

VERIFIED REPAIR

Restore the contract rule at the change at period end step: use `if x['change'] >= x['end'] or x['change'] < x['start']:`.

Unsuccessful approach: The attempt only skips same-price changes, so changes before the period start are prorated.

Case contract

Input unix-second {start, end, change} and {old, qold, new, qnew}. If change < start or change >= end return []. Otherwise left = end - change, span = end - start. An "unused" credit line of -(old*qold*left/span) and a "remaining" line of new*qnew*left/span are emitted, each magnitude rounded half-up (half away from zero), omitting a line whose price*quantity is 0. Return [[kind, amount]].

Why this case matters

Timestamp-based proration produces separate credit and debit lines whose rounding and emission rules show on the invoice.

1 / The failure

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

N = 1
observations = []
def solve(x):
    if x['change'] > x['end'] or x['change'] < x['start']:
        return []
    span = x['end'] - x['start']
    left = x['end'] - x['change']
    def hu(n):
        return (n * 2 + span) // (2 * span)
    lines = []
    if x['old'] * x['qold']:
        lines.append(['unused', -hu(x['old'] * x['qold'] * left)])
    if x['new'] * x['qnew']:
        lines.append(['remaining', hu(x['new'] * x['qnew'] * left)])
    return lines
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'start': 1704011568, 'end': 1706689968, 'change': 1706689968, 'old': 1000, 'qold': 3, 'new': 1500, 'qnew': 3}, []), ('regression', {'start': 1728579559, 'end': 1760115559, 'change': 1760115559, 'old': 0, 'qold': 0, 'new': 51264, 'qnew': 1}, []), ('partial-repair probe', {'start': 1737228310, 'end': 1739499785, 'change': 1739499795, 'old': 178, 'qold': 1, 'new': 1500, 'qnew': 1}, []), ('partial-repair probe', {'start': 1720297909, 'end': 1720623118, 'change': 1720623118, 'old': 1000, 'qold': 17, 'new': 0, 'qnew': 0}, []), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 3, 'qold': 1, 'new': 5, 'qnew': 1}, [['unused', -2], ['remaining', 3]]), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 5, 'qold': 1, 'new': 7, 'qnew': 1}, [['unused', -3], ['remaining', 4]]), ('normal control', {'start': 1718898066, 'end': 1722579184, 'change': 1721183532, 'old': 87270, 'qold': 0, 'new': 4900, 'qnew': 1}, [['remaining', 1858]]), ('normal control', {'start': 1726549577, 'end': 1727154377, 'change': 1726962866, 'old': 2500, 'qold': 0, 'new': 0, 'qnew': 0}, []), ('normal control', {'start': 1732894162, 'end': 1735486162, 'change': 1732894162, 'old': 1000, 'qold': 2, 'new': 91004, 'qnew': 0}, [['unused', -2000]]), ('normal control', {'start': 1749969117, 'end': 1752647517, 'change': 1751393656, 'old': 63152, 'qold': 13, 'new': 0, 'qnew': 0}, [['unused', -384330]])], [('regression', {'start': 1728579559, 'end': 1760115559, 'change': 1760115559, 'old': 0, 'qold': 0, 'new': 51264, 'qnew': 1}, []), ('regression', {'start': 1720297909, 'end': 1720623118, 'change': 1720623118, 'old': 1000, 'qold': 17, 'new': 0, 'qnew': 0}, []), ('partial-repair probe', {'start': 1734629848, 'end': 1766165848, 'change': 1766165848, 'old': 1000, 'qold': 1, 'new': 4900, 'qnew': 1}, []), ('partial-repair probe', {'start': 1742436208, 'end': 1773972208, 'change': 1773972218, 'old': 0, 'qold': 3, 'new': 4900, 'qnew': 1}, []), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 7, 'qold': 1, 'new': 9, 'qnew': 1}, [['unused', -4], ['remaining', 5]]), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 9, 'qold': 1, 'new': 11, 'qnew': 1}, [['unused', -5], ['remaining', 6]]), ('normal control', {'start': 1700089359, 'end': 1702545450, 'change': 1702420392, 'old': 79079, 'qold': 0, 'new': 0, 'qnew': 5}, []), ('normal control', {'start': 1721814513, 'end': 1722419313, 'change': 1722419313, 'old': 0, 'qold': 3, 'new': 0, 'qnew': 5}, []), ('normal control', {'start': 1759524018, 'end': 1763871464, 'change': 1759976835, 'old': 0, 'qold': 0, 'new': 1500, 'qnew': 5}, [['remaining', 6719]]), ('normal control', {'start': 1759898518, 'end': 1762576918, 'change': 1760952409, 'old': 0, 'qold': 3, 'new': 37669, 'qnew': 0}, [])], [('regression', {'start': 1720297909, 'end': 1720623118, 'change': 1720623118, 'old': 1000, 'qold': 17, 'new': 0, 'qnew': 0}, []), ('regression', {'start': 1734629848, 'end': 1766165848, 'change': 1766165848, 'old': 1000, 'qold': 1, 'new': 4900, 'qnew': 1}, []), ('partial-repair probe', {'start': 1742436208, 'end': 1773972208, 'change': 1773972218, 'old': 0, 'qold': 3, 'new': 4900, 'qnew': 1}, []), ('partial-repair probe', {'start': 1739738740, 'end': 1771274740, 'change': 1771274740, 'old': 2500, 'qold': 3, 'new': 1500, 'qnew': 5}, []), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 11, 'qold': 1, 'new': 13, 'qnew': 1}, [['unused', -6], ['remaining', 7]]), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 13, 'qold': 1, 'new': 15, 'qnew': 1}, [['unused', -7], ['remaining', 8]]), ('normal control', {'start': 1724743049, 'end': 1756279049, 'change': 1724743049, 'old': 2500, 'qold': 1, 'new': 1500, 'qnew': 1}, [['unused', -2500], ['remaining', 1500]]), ('normal control', {'start': 1757847857, 'end': 1760439857, 'change': 1757847852, 'old': 92286, 'qold': 0, 'new': 0, 'qnew': 4}, []), ('normal control', {'start': 1726496239, 'end': 1729174639, 'change': 1726496239, 'old': 73990, 'qold': 3, 'new': 47429, 'qnew': 5}, [['unused', -221970], ['remaining', 237145]]), ('normal control', {'start': 1753105090, 'end': 1753709890, 'change': 1753105090, 'old': 1000, 'qold': 0, 'new': 0, 'qnew': 1}, [])], [('regression', {'start': 1734629848, 'end': 1766165848, 'change': 1766165848, 'old': 1000, 'qold': 1, 'new': 4900, 'qnew': 1}, []), ('regression', {'start': 1739738740, 'end': 1771274740, 'change': 1771274740, 'old': 2500, 'qold': 3, 'new': 1500, 'qnew': 5}, []), ('partial-repair probe', {'start': 1725551908, 'end': 1757087908, 'change': 1757087918, 'old': 67119, 'qold': 3, 'new': 4900, 'qnew': 13}, []), ('partial-repair probe', {'start': 1716957129, 'end': 1717561929, 'change': 1716957124, 'old': 1000, 'qold': 7, 'new': 0, 'qnew': 5}, []), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 3, 'qold': 1, 'new': 5, 'qnew': 1}, [['unused', -2], ['remaining', 3]]), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 5, 'qold': 1, 'new': 7, 'qnew': 1}, [['unused', -3], ['remaining', 4]]), ('normal control', {'start': 1739142581, 'end': 1739747381, 'change': 1739142581, 'old': 26706, 'qold': 3, 'new': 1500, 'qnew': 5}, [['unused', -80118], ['remaining', 7500]]), ('normal control', {'start': 1742150000, 'end': 1745617539, 'change': 1744739339, 'old': 2500, 'qold': 3, 'new': 0, 'qnew': 1}, [['unused', -1899]]), ('normal control', {'start': 1733742690, 'end': 1736421090, 'change': 1733742690, 'old': 0, 'qold': 3, 'new': 4900, 'qnew': 14}, [['remaining', 68600]]), ('normal control', {'start': 1734436882, 'end': 1765972882, 'change': 1756322121, 'old': 10374, 'qold': 1, 'new': 4900, 'qnew': 1}, [['unused', -3175], ['remaining', 1500]])], [('regression', {'start': 1739738740, 'end': 1771274740, 'change': 1771274740, 'old': 2500, 'qold': 3, 'new': 1500, 'qnew': 5}, []), ('regression', {'start': 1705101716, 'end': 1707693716, 'change': 1707693716, 'old': 2500, 'qold': 3, 'new': 33949, 'qnew': 0}, []), ('partial-repair probe', {'start': 1716957129, 'end': 1717561929, 'change': 1716957124, 'old': 1000, 'qold': 7, 'new': 0, 'qnew': 5}, []), ('partial-repair probe', {'start': 1724685898, 'end': 1728923706, 'change': 1728923716, 'old': 2500, 'qold': 3, 'new': 1500, 'qnew': 1}, []), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 7, 'qold': 1, 'new': 9, 'qnew': 1}, [['unused', -4], ['remaining', 5]]), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 9, 'qold': 1, 'new': 11, 'qnew': 1}, [['unused', -5], ['remaining', 6]]), ('normal control', {'start': 1726598960, 'end': 1727203760, 'change': 1726783107, 'old': 2500, 'qold': 0, 'new': 4900, 'qnew': 0}, []), ('normal control', {'start': 1720771881, 'end': 1723680029, 'change': 1720771876, 'old': 38840, 'qold': 0, 'new': 0, 'qnew': 5}, []), ('normal control', {'start': 1742110108, 'end': 1745693685, 'change': 1744431348, 'old': 2500, 'qold': 1, 'new': 1500, 'qnew': 5}, [['unused', -881], ['remaining', 2642]]), ('normal control', {'start': 1724364420, 'end': 1726956420, 'change': 1724364420, 'old': 1000, 'qold': 3, 'new': 0, 'qnew': 0}, [['unused', -3000]])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), 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
regression 0[['unused', 0], ['remaining', 0]][]Failed
regression 1[['remaining', 0]][]Failed
partial-repair probe 2[][]Passed
partial-repair probe 3[['unused', 0]][]Failed
boundary control 4[['unused', -2], ['remaining', 3]][['unused', -2], ['remaining', 3]]Passed
boundary control 5[['unused', -3], ['remaining', 4]][['unused', -3], ['remaining', 4]]Passed
normal control 6[['remaining', 1858]][['remaining', 1858]]Passed
normal control 7[][]Passed
normal control 8[['unused', -2000]][['unused', -2000]]Passed
normal control 9[['unused', -384330]][['unused', -384330]]Passed

SHA-256 / 239436b468ee43ca279f6c86cec94715f5cc6a65302cc6afd4ba297f5bef93f5

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    if x['change'] >= x['end'] and x['old'] == x['new']:
        return []
    span = x['end'] - x['start']
    left = x['end'] - x['change']
    def hu(n):
        return (n * 2 + span) // (2 * span)
    lines = []
    if x['old'] * x['qold']:
        lines.append(['unused', -hu(x['old'] * x['qold'] * left)])
    if x['new'] * x['qnew']:
        lines.append(['remaining', hu(x['new'] * x['qnew'] * left)])
    return lines
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'start': 1704011568, 'end': 1706689968, 'change': 1706689968, 'old': 1000, 'qold': 3, 'new': 1500, 'qnew': 3}, []), ('regression', {'start': 1728579559, 'end': 1760115559, 'change': 1760115559, 'old': 0, 'qold': 0, 'new': 51264, 'qnew': 1}, []), ('partial-repair probe', {'start': 1737228310, 'end': 1739499785, 'change': 1739499795, 'old': 178, 'qold': 1, 'new': 1500, 'qnew': 1}, []), ('partial-repair probe', {'start': 1720297909, 'end': 1720623118, 'change': 1720623118, 'old': 1000, 'qold': 17, 'new': 0, 'qnew': 0}, []), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 3, 'qold': 1, 'new': 5, 'qnew': 1}, [['unused', -2], ['remaining', 3]]), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 5, 'qold': 1, 'new': 7, 'qnew': 1}, [['unused', -3], ['remaining', 4]]), ('normal control', {'start': 1718898066, 'end': 1722579184, 'change': 1721183532, 'old': 87270, 'qold': 0, 'new': 4900, 'qnew': 1}, [['remaining', 1858]]), ('normal control', {'start': 1726549577, 'end': 1727154377, 'change': 1726962866, 'old': 2500, 'qold': 0, 'new': 0, 'qnew': 0}, []), ('normal control', {'start': 1732894162, 'end': 1735486162, 'change': 1732894162, 'old': 1000, 'qold': 2, 'new': 91004, 'qnew': 0}, [['unused', -2000]]), ('normal control', {'start': 1749969117, 'end': 1752647517, 'change': 1751393656, 'old': 63152, 'qold': 13, 'new': 0, 'qnew': 0}, [['unused', -384330]])], [('regression', {'start': 1728579559, 'end': 1760115559, 'change': 1760115559, 'old': 0, 'qold': 0, 'new': 51264, 'qnew': 1}, []), ('regression', {'start': 1720297909, 'end': 1720623118, 'change': 1720623118, 'old': 1000, 'qold': 17, 'new': 0, 'qnew': 0}, []), ('partial-repair probe', {'start': 1734629848, 'end': 1766165848, 'change': 1766165848, 'old': 1000, 'qold': 1, 'new': 4900, 'qnew': 1}, []), ('partial-repair probe', {'start': 1742436208, 'end': 1773972208, 'change': 1773972218, 'old': 0, 'qold': 3, 'new': 4900, 'qnew': 1}, []), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 7, 'qold': 1, 'new': 9, 'qnew': 1}, [['unused', -4], ['remaining', 5]]), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 9, 'qold': 1, 'new': 11, 'qnew': 1}, [['unused', -5], ['remaining', 6]]), ('normal control', {'start': 1700089359, 'end': 1702545450, 'change': 1702420392, 'old': 79079, 'qold': 0, 'new': 0, 'qnew': 5}, []), ('normal control', {'start': 1721814513, 'end': 1722419313, 'change': 1722419313, 'old': 0, 'qold': 3, 'new': 0, 'qnew': 5}, []), ('normal control', {'start': 1759524018, 'end': 1763871464, 'change': 1759976835, 'old': 0, 'qold': 0, 'new': 1500, 'qnew': 5}, [['remaining', 6719]]), ('normal control', {'start': 1759898518, 'end': 1762576918, 'change': 1760952409, 'old': 0, 'qold': 3, 'new': 37669, 'qnew': 0}, [])], [('regression', {'start': 1720297909, 'end': 1720623118, 'change': 1720623118, 'old': 1000, 'qold': 17, 'new': 0, 'qnew': 0}, []), ('regression', {'start': 1734629848, 'end': 1766165848, 'change': 1766165848, 'old': 1000, 'qold': 1, 'new': 4900, 'qnew': 1}, []), ('partial-repair probe', {'start': 1742436208, 'end': 1773972208, 'change': 1773972218, 'old': 0, 'qold': 3, 'new': 4900, 'qnew': 1}, []), ('partial-repair probe', {'start': 1739738740, 'end': 1771274740, 'change': 1771274740, 'old': 2500, 'qold': 3, 'new': 1500, 'qnew': 5}, []), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 11, 'qold': 1, 'new': 13, 'qnew': 1}, [['unused', -6], ['remaining', 7]]), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 13, 'qold': 1, 'new': 15, 'qnew': 1}, [['unused', -7], ['remaining', 8]]), ('normal control', {'start': 1724743049, 'end': 1756279049, 'change': 1724743049, 'old': 2500, 'qold': 1, 'new': 1500, 'qnew': 1}, [['unused', -2500], ['remaining', 1500]]), ('normal control', {'start': 1757847857, 'end': 1760439857, 'change': 1757847852, 'old': 92286, 'qold': 0, 'new': 0, 'qnew': 4}, []), ('normal control', {'start': 1726496239, 'end': 1729174639, 'change': 1726496239, 'old': 73990, 'qold': 3, 'new': 47429, 'qnew': 5}, [['unused', -221970], ['remaining', 237145]]), ('normal control', {'start': 1753105090, 'end': 1753709890, 'change': 1753105090, 'old': 1000, 'qold': 0, 'new': 0, 'qnew': 1}, [])], [('regression', {'start': 1734629848, 'end': 1766165848, 'change': 1766165848, 'old': 1000, 'qold': 1, 'new': 4900, 'qnew': 1}, []), ('regression', {'start': 1739738740, 'end': 1771274740, 'change': 1771274740, 'old': 2500, 'qold': 3, 'new': 1500, 'qnew': 5}, []), ('partial-repair probe', {'start': 1725551908, 'end': 1757087908, 'change': 1757087918, 'old': 67119, 'qold': 3, 'new': 4900, 'qnew': 13}, []), ('partial-repair probe', {'start': 1716957129, 'end': 1717561929, 'change': 1716957124, 'old': 1000, 'qold': 7, 'new': 0, 'qnew': 5}, []), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 3, 'qold': 1, 'new': 5, 'qnew': 1}, [['unused', -2], ['remaining', 3]]), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 5, 'qold': 1, 'new': 7, 'qnew': 1}, [['unused', -3], ['remaining', 4]]), ('normal control', {'start': 1739142581, 'end': 1739747381, 'change': 1739142581, 'old': 26706, 'qold': 3, 'new': 1500, 'qnew': 5}, [['unused', -80118], ['remaining', 7500]]), ('normal control', {'start': 1742150000, 'end': 1745617539, 'change': 1744739339, 'old': 2500, 'qold': 3, 'new': 0, 'qnew': 1}, [['unused', -1899]]), ('normal control', {'start': 1733742690, 'end': 1736421090, 'change': 1733742690, 'old': 0, 'qold': 3, 'new': 4900, 'qnew': 14}, [['remaining', 68600]]), ('normal control', {'start': 1734436882, 'end': 1765972882, 'change': 1756322121, 'old': 10374, 'qold': 1, 'new': 4900, 'qnew': 1}, [['unused', -3175], ['remaining', 1500]])], [('regression', {'start': 1739738740, 'end': 1771274740, 'change': 1771274740, 'old': 2500, 'qold': 3, 'new': 1500, 'qnew': 5}, []), ('regression', {'start': 1705101716, 'end': 1707693716, 'change': 1707693716, 'old': 2500, 'qold': 3, 'new': 33949, 'qnew': 0}, []), ('partial-repair probe', {'start': 1716957129, 'end': 1717561929, 'change': 1716957124, 'old': 1000, 'qold': 7, 'new': 0, 'qnew': 5}, []), ('partial-repair probe', {'start': 1724685898, 'end': 1728923706, 'change': 1728923716, 'old': 2500, 'qold': 3, 'new': 1500, 'qnew': 1}, []), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 7, 'qold': 1, 'new': 9, 'qnew': 1}, [['unused', -4], ['remaining', 5]]), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 9, 'qold': 1, 'new': 11, 'qnew': 1}, [['unused', -5], ['remaining', 6]]), ('normal control', {'start': 1726598960, 'end': 1727203760, 'change': 1726783107, 'old': 2500, 'qold': 0, 'new': 4900, 'qnew': 0}, []), ('normal control', {'start': 1720771881, 'end': 1723680029, 'change': 1720771876, 'old': 38840, 'qold': 0, 'new': 0, 'qnew': 5}, []), ('normal control', {'start': 1742110108, 'end': 1745693685, 'change': 1744431348, 'old': 2500, 'qold': 1, 'new': 1500, 'qnew': 5}, [['unused', -881], ['remaining', 2642]]), ('normal control', {'start': 1724364420, 'end': 1726956420, 'change': 1724364420, 'old': 1000, 'qold': 3, 'new': 0, 'qnew': 0}, [['unused', -3000]])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), 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
regression 0[['unused', 0], ['remaining', 0]][]Failed
regression 1[['remaining', 0]][]Failed
partial-repair probe 2[['unused', 0], ['remaining', 0]][]Failed
partial-repair probe 3[['unused', 0]][]Failed
boundary control 4[['unused', -2], ['remaining', 3]][['unused', -2], ['remaining', 3]]Passed
boundary control 5[['unused', -3], ['remaining', 4]][['unused', -3], ['remaining', 4]]Passed
normal control 6[['remaining', 1858]][['remaining', 1858]]Passed
normal control 7[][]Passed
normal control 8[['unused', -2000]][['unused', -2000]]Passed
normal control 9[['unused', -384330]][['unused', -384330]]Passed

SHA-256 / 73689617eff0b1817eb596c79247c96a135c4428db0d89a4e617800e20c6fb2e

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    if x['change'] >= x['end'] or x['change'] < x['start']:
        return []
    span = x['end'] - x['start']
    left = x['end'] - x['change']
    def hu(n):
        return (n * 2 + span) // (2 * span)
    lines = []
    if x['old'] * x['qold']:
        lines.append(['unused', -hu(x['old'] * x['qold'] * left)])
    if x['new'] * x['qnew']:
        lines.append(['remaining', hu(x['new'] * x['qnew'] * left)])
    return lines
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'start': 1704011568, 'end': 1706689968, 'change': 1706689968, 'old': 1000, 'qold': 3, 'new': 1500, 'qnew': 3}, []), ('regression', {'start': 1728579559, 'end': 1760115559, 'change': 1760115559, 'old': 0, 'qold': 0, 'new': 51264, 'qnew': 1}, []), ('partial-repair probe', {'start': 1737228310, 'end': 1739499785, 'change': 1739499795, 'old': 178, 'qold': 1, 'new': 1500, 'qnew': 1}, []), ('partial-repair probe', {'start': 1720297909, 'end': 1720623118, 'change': 1720623118, 'old': 1000, 'qold': 17, 'new': 0, 'qnew': 0}, []), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 3, 'qold': 1, 'new': 5, 'qnew': 1}, [['unused', -2], ['remaining', 3]]), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 5, 'qold': 1, 'new': 7, 'qnew': 1}, [['unused', -3], ['remaining', 4]]), ('normal control', {'start': 1718898066, 'end': 1722579184, 'change': 1721183532, 'old': 87270, 'qold': 0, 'new': 4900, 'qnew': 1}, [['remaining', 1858]]), ('normal control', {'start': 1726549577, 'end': 1727154377, 'change': 1726962866, 'old': 2500, 'qold': 0, 'new': 0, 'qnew': 0}, []), ('normal control', {'start': 1732894162, 'end': 1735486162, 'change': 1732894162, 'old': 1000, 'qold': 2, 'new': 91004, 'qnew': 0}, [['unused', -2000]]), ('normal control', {'start': 1749969117, 'end': 1752647517, 'change': 1751393656, 'old': 63152, 'qold': 13, 'new': 0, 'qnew': 0}, [['unused', -384330]])], [('regression', {'start': 1728579559, 'end': 1760115559, 'change': 1760115559, 'old': 0, 'qold': 0, 'new': 51264, 'qnew': 1}, []), ('regression', {'start': 1720297909, 'end': 1720623118, 'change': 1720623118, 'old': 1000, 'qold': 17, 'new': 0, 'qnew': 0}, []), ('partial-repair probe', {'start': 1734629848, 'end': 1766165848, 'change': 1766165848, 'old': 1000, 'qold': 1, 'new': 4900, 'qnew': 1}, []), ('partial-repair probe', {'start': 1742436208, 'end': 1773972208, 'change': 1773972218, 'old': 0, 'qold': 3, 'new': 4900, 'qnew': 1}, []), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 7, 'qold': 1, 'new': 9, 'qnew': 1}, [['unused', -4], ['remaining', 5]]), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 9, 'qold': 1, 'new': 11, 'qnew': 1}, [['unused', -5], ['remaining', 6]]), ('normal control', {'start': 1700089359, 'end': 1702545450, 'change': 1702420392, 'old': 79079, 'qold': 0, 'new': 0, 'qnew': 5}, []), ('normal control', {'start': 1721814513, 'end': 1722419313, 'change': 1722419313, 'old': 0, 'qold': 3, 'new': 0, 'qnew': 5}, []), ('normal control', {'start': 1759524018, 'end': 1763871464, 'change': 1759976835, 'old': 0, 'qold': 0, 'new': 1500, 'qnew': 5}, [['remaining', 6719]]), ('normal control', {'start': 1759898518, 'end': 1762576918, 'change': 1760952409, 'old': 0, 'qold': 3, 'new': 37669, 'qnew': 0}, [])], [('regression', {'start': 1720297909, 'end': 1720623118, 'change': 1720623118, 'old': 1000, 'qold': 17, 'new': 0, 'qnew': 0}, []), ('regression', {'start': 1734629848, 'end': 1766165848, 'change': 1766165848, 'old': 1000, 'qold': 1, 'new': 4900, 'qnew': 1}, []), ('partial-repair probe', {'start': 1742436208, 'end': 1773972208, 'change': 1773972218, 'old': 0, 'qold': 3, 'new': 4900, 'qnew': 1}, []), ('partial-repair probe', {'start': 1739738740, 'end': 1771274740, 'change': 1771274740, 'old': 2500, 'qold': 3, 'new': 1500, 'qnew': 5}, []), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 11, 'qold': 1, 'new': 13, 'qnew': 1}, [['unused', -6], ['remaining', 7]]), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 13, 'qold': 1, 'new': 15, 'qnew': 1}, [['unused', -7], ['remaining', 8]]), ('normal control', {'start': 1724743049, 'end': 1756279049, 'change': 1724743049, 'old': 2500, 'qold': 1, 'new': 1500, 'qnew': 1}, [['unused', -2500], ['remaining', 1500]]), ('normal control', {'start': 1757847857, 'end': 1760439857, 'change': 1757847852, 'old': 92286, 'qold': 0, 'new': 0, 'qnew': 4}, []), ('normal control', {'start': 1726496239, 'end': 1729174639, 'change': 1726496239, 'old': 73990, 'qold': 3, 'new': 47429, 'qnew': 5}, [['unused', -221970], ['remaining', 237145]]), ('normal control', {'start': 1753105090, 'end': 1753709890, 'change': 1753105090, 'old': 1000, 'qold': 0, 'new': 0, 'qnew': 1}, [])], [('regression', {'start': 1734629848, 'end': 1766165848, 'change': 1766165848, 'old': 1000, 'qold': 1, 'new': 4900, 'qnew': 1}, []), ('regression', {'start': 1739738740, 'end': 1771274740, 'change': 1771274740, 'old': 2500, 'qold': 3, 'new': 1500, 'qnew': 5}, []), ('partial-repair probe', {'start': 1725551908, 'end': 1757087908, 'change': 1757087918, 'old': 67119, 'qold': 3, 'new': 4900, 'qnew': 13}, []), ('partial-repair probe', {'start': 1716957129, 'end': 1717561929, 'change': 1716957124, 'old': 1000, 'qold': 7, 'new': 0, 'qnew': 5}, []), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 3, 'qold': 1, 'new': 5, 'qnew': 1}, [['unused', -2], ['remaining', 3]]), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 5, 'qold': 1, 'new': 7, 'qnew': 1}, [['unused', -3], ['remaining', 4]]), ('normal control', {'start': 1739142581, 'end': 1739747381, 'change': 1739142581, 'old': 26706, 'qold': 3, 'new': 1500, 'qnew': 5}, [['unused', -80118], ['remaining', 7500]]), ('normal control', {'start': 1742150000, 'end': 1745617539, 'change': 1744739339, 'old': 2500, 'qold': 3, 'new': 0, 'qnew': 1}, [['unused', -1899]]), ('normal control', {'start': 1733742690, 'end': 1736421090, 'change': 1733742690, 'old': 0, 'qold': 3, 'new': 4900, 'qnew': 14}, [['remaining', 68600]]), ('normal control', {'start': 1734436882, 'end': 1765972882, 'change': 1756322121, 'old': 10374, 'qold': 1, 'new': 4900, 'qnew': 1}, [['unused', -3175], ['remaining', 1500]])], [('regression', {'start': 1739738740, 'end': 1771274740, 'change': 1771274740, 'old': 2500, 'qold': 3, 'new': 1500, 'qnew': 5}, []), ('regression', {'start': 1705101716, 'end': 1707693716, 'change': 1707693716, 'old': 2500, 'qold': 3, 'new': 33949, 'qnew': 0}, []), ('partial-repair probe', {'start': 1716957129, 'end': 1717561929, 'change': 1716957124, 'old': 1000, 'qold': 7, 'new': 0, 'qnew': 5}, []), ('partial-repair probe', {'start': 1724685898, 'end': 1728923706, 'change': 1728923716, 'old': 2500, 'qold': 3, 'new': 1500, 'qnew': 1}, []), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 7, 'qold': 1, 'new': 9, 'qnew': 1}, [['unused', -4], ['remaining', 5]]), ('boundary control', {'start': 1000, 'end': 2000, 'change': 1500, 'old': 9, 'qold': 1, 'new': 11, 'qnew': 1}, [['unused', -5], ['remaining', 6]]), ('normal control', {'start': 1726598960, 'end': 1727203760, 'change': 1726783107, 'old': 2500, 'qold': 0, 'new': 4900, 'qnew': 0}, []), ('normal control', {'start': 1720771881, 'end': 1723680029, 'change': 1720771876, 'old': 38840, 'qold': 0, 'new': 0, 'qnew': 5}, []), ('normal control', {'start': 1742110108, 'end': 1745693685, 'change': 1744431348, 'old': 2500, 'qold': 1, 'new': 1500, 'qnew': 5}, [['unused', -881], ['remaining', 2642]]), ('normal control', {'start': 1724364420, 'end': 1726956420, 'change': 1724364420, 'old': 1000, 'qold': 3, 'new': 0, 'qnew': 0}, [['unused', -3000]])]]
for i, (label, args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (label, i), 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
regression 0[][]Passed
regression 1[][]Passed
partial-repair probe 2[][]Passed
partial-repair probe 3[][]Passed
boundary control 4[['unused', -2], ['remaining', 3]][['unused', -2], ['remaining', 3]]Passed
boundary control 5[['unused', -3], ['remaining', 4]][['unused', -3], ['remaining', 4]]Passed
normal control 6[['remaining', 1858]][['remaining', 1858]]Passed
normal control 7[][]Passed
normal control 8[['unused', -2000]][['unused', -2000]]Passed
normal control 9[['unused', -384330]][['unused', -384330]]Passed

SHA-256 / 6e9494073b9d2183f4cb1109230a02ffb4c3d949eb7b2aa8717767d5d77daf02

Verification & scope

A deterministic teaching model of a stipulated billing rule. It makes no claim to reproduce any billing provider's exact behaviour and is not billing software. 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:35.625615+00:00.

Case digest / 9966948c97339717ebd85e0f5974731838c1256816dcf5bce88c30f0cd145a7f