FA-59006 / Payroll withholding rules / Open access
Overtime regular rate with bonuses and differentials: premium cent rounding · case 01
Overtime premiums ending in a half cent or more are a cent short.
ROOT CAUSE
The premium is truncated toward zero rather than rounded half-up.
THE FAILURE
The premium is truncated toward zero rather than rounded half-up.
Unsuccessful approach: The attempt uses round(), which rounds exact half cents to even, so half of the tie cases are still short.
Case contract
Input weekly {hours, rate, bonus, discretionary, diff_hours, diff}. Straight pay = hours*rate + diff_hours*diff. Regular rate = (straight pay + bonus unless discretionary) / hours. Overtime premium = regular rate * max(0, hours-40) / 2, rounded half-up to the cent. Total = straight pay + bonus + premium. Zero hours returns [0, bonus]. Return [premium, total].
Why this case matters
Nondiscretionary bonuses and shift differentials raise the regular rate, and only a half-time premium is owed on top of straight-time pay.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(x):
h = x['hours']
base = h * x['rate'] + x['diff_hours'] * x['diff']
included = base + (0 if x['discretionary'] else x['bonus'])
if h == 0:
return [0, x['bonus']]
ot = max(0, h - 40)
rr = Fraction(included, h)
premium = rr * ot / 2
prem_c = int(premium)
total = base + x['bonus'] + prem_c
return [prem_c, total]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'hours': 58, 'rate': 1280, 'bonus': 145, 'discretionary': False, 'diff_hours': 5, 'diff': 0}, [11543, 85928]), ('regression', {'hours': 48, 'rate': 2361, 'bonus': 0, 'discretionary': False, 'diff_hours': 15, 'diff': 150}, [9632, 125210]), ('partial-repair probe', {'hours': 55, 'rate': 3779, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [28343, 236188]), ('partial-repair probe', {'hours': 50, 'rate': 3473, 'bonus': 15335, 'discretionary': False, 'diff_hours': 14, 'diff': 0}, [18899, 207884]), ('normal control', {'hours': 56, 'rate': 2894, 'bonus': 0, 'discretionary': True, 'diff_hours': 20, 'diff': 189}, [23692, 189536]), ('normal control', {'hours': 29, 'rate': 3185, 'bonus': 18960, 'discretionary': True, 'diff_hours': 0, 'diff': 235}, [0, 111325]), ('normal control', {'hours': 15, 'rate': 1913, 'bonus': 0, 'discretionary': False, 'diff_hours': 3, 'diff': 100}, [0, 28995]), ('normal control', {'hours': 42, 'rate': 2619, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [2619, 112617])], [('regression', {'hours': 55, 'rate': 3779, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [28343, 236188]), ('regression', {'hours': 45, 'rate': 1070, 'bonus': 6593, 'discretionary': True, 'diff_hours': 3, 'diff': 100}, [2692, 57735]), ('partial-repair probe', {'hours': 50, 'rate': 3473, 'bonus': 15335, 'discretionary': False, 'diff_hours': 14, 'diff': 0}, [18899, 207884]), ('partial-repair probe', {'hours': 49, 'rate': 2297, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [10337, 122890]), ('normal control', {'hours': 36, 'rate': 1564, 'bonus': 12440, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [0, 68744]), ('normal control', {'hours': 36, 'rate': 3124, 'bonus': 20788, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 133252]), ('normal control', {'hours': 38, 'rate': 3803, 'bonus': 0, 'discretionary': False, 'diff_hours': 5, 'diff': 175}, [0, 145389]), ('normal control', {'hours': 42, 'rate': 1092, 'bonus': 0, 'discretionary': False, 'diff_hours': 2, 'diff': 157}, [1099, 47277])], [('regression', {'hours': 50, 'rate': 3473, 'bonus': 15335, 'discretionary': False, 'diff_hours': 14, 'diff': 0}, [18899, 207884]), ('regression', {'hours': 60, 'rate': 3726, 'bonus': 328, 'discretionary': False, 'diff_hours': 13, 'diff': 0}, [37315, 261203]), ('partial-repair probe', {'hours': 59, 'rate': 1183, 'bonus': 15895, 'discretionary': True, 'diff_hours': 0, 'diff': 111}, [11239, 96931]), ('partial-repair probe', {'hours': 45, 'rate': 3152, 'bonus': 297, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [7897, 150034]), ('normal control', {'hours': 40, 'rate': 2368, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 94720]), ('normal control', {'hours': 41, 'rate': 1070, 'bonus': 0, 'discretionary': False, 'diff_hours': 14, 'diff': 300}, [586, 48656]), ('normal control', {'hours': 15, 'rate': 1275, 'bonus': 16297, 'discretionary': False, 'diff_hours': 0, 'diff': 100}, [0, 35422]), ('normal control', {'hours': 0, 'rate': 1235, 'bonus': 452, 'discretionary': False, 'diff_hours': 15, 'diff': 0}, [0, 452])], [('regression', {'hours': 49, 'rate': 2297, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [10337, 122890]), ('regression', {'hours': 51, 'rate': 1430, 'bonus': 583, 'discretionary': True, 'diff_hours': 17, 'diff': 212}, [8254, 85371]), ('partial-repair probe', {'hours': 49, 'rate': 1393, 'bonus': 1015, 'discretionary': True, 'diff_hours': 13, 'diff': 0}, [6269, 75541]), ('partial-repair probe', {'hours': 41, 'rate': 3985, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 218}, [1993, 165378]), ('normal control', {'hours': 25, 'rate': 2784, 'bonus': 431, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [0, 70031]), ('normal control', {'hours': 49, 'rate': 2740, 'bonus': 1615, 'discretionary': True, 'diff_hours': 20, 'diff': 0}, [12330, 148205]), ('normal control', {'hours': 4, 'rate': 2630, 'bonus': 24821, 'discretionary': False, 'diff_hours': 10, 'diff': 100}, [0, 36341]), ('normal control', {'hours': 36, 'rate': 3824, 'bonus': 0, 'discretionary': False, 'diff_hours': 12, 'diff': 100}, [0, 138864])], [('regression', {'hours': 59, 'rate': 1183, 'bonus': 15895, 'discretionary': True, 'diff_hours': 0, 'diff': 111}, [11239, 96931]), ('regression', {'hours': 41, 'rate': 1051, 'bonus': 26, 'discretionary': False, 'diff_hours': 0, 'diff': 259}, [526, 43643]), ('partial-repair probe', {'hours': 41, 'rate': 1613, 'bonus': 28839, 'discretionary': True, 'diff_hours': 0, 'diff': 100}, [807, 95779]), ('partial-repair probe', {'hours': 59, 'rate': 3943, 'bonus': 3183, 'discretionary': True, 'diff_hours': 0, 'diff': 50}, [37459, 273279]), ('normal control', {'hours': 51, 'rate': 3958, 'bonus': 443, 'discretionary': True, 'diff_hours': 0, 'diff': 100}, [21769, 224070]), ('normal control', {'hours': 36, 'rate': 3363, 'bonus': 0, 'discretionary': True, 'diff_hours': 0, 'diff': 0}, [0, 121068]), ('normal control', {'hours': 25, 'rate': 1555, 'bonus': 17670, 'discretionary': True, 'diff_hours': 0, 'diff': 150}, [0, 56545]), ('normal control', {'hours': 13, 'rate': 3420, 'bonus': 0, 'discretionary': True, 'diff_hours': 0, 'diff': 150}, [0, 44460])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression 0 | [11542, 85927] | [11543, 85928] | Failed |
| regression 1 | [9631, 125209] | [9632, 125210] | Failed |
| partial-repair probe 2 | [28342, 236187] | [28343, 236188] | Failed |
| partial-repair probe 3 | [18898, 207883] | [18899, 207884] | Failed |
| normal control 4 | [23692, 189536] | [23692, 189536] | Passed |
| normal control 5 | [0, 111325] | [0, 111325] | Passed |
| normal control 6 | [0, 28995] | [0, 28995] | Passed |
| normal control 7 | [2619, 112617] | [2619, 112617] | Passed |
SHA-256 / 082294bb524a93462cc4c54e8aa4965c730c57365d7f453ba2478d351dc4fe21
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
import math
N = 1
observations = []
def solve(x):
h = x['hours']
base = h * x['rate'] + x['diff_hours'] * x['diff']
included = base + (0 if x['discretionary'] else x['bonus'])
if h == 0:
return [0, x['bonus']]
ot = max(0, h - 40)
rr = Fraction(included, h)
premium = rr * ot / 2
prem_c = round(premium)
total = base + x['bonus'] + prem_c
return [prem_c, total]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression', {'hours': 58, 'rate': 1280, 'bonus': 145, 'discretionary': False, 'diff_hours': 5, 'diff': 0}, [11543, 85928]), ('regression', {'hours': 48, 'rate': 2361, 'bonus': 0, 'discretionary': False, 'diff_hours': 15, 'diff': 150}, [9632, 125210]), ('partial-repair probe', {'hours': 55, 'rate': 3779, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [28343, 236188]), ('partial-repair probe', {'hours': 50, 'rate': 3473, 'bonus': 15335, 'discretionary': False, 'diff_hours': 14, 'diff': 0}, [18899, 207884]), ('normal control', {'hours': 56, 'rate': 2894, 'bonus': 0, 'discretionary': True, 'diff_hours': 20, 'diff': 189}, [23692, 189536]), ('normal control', {'hours': 29, 'rate': 3185, 'bonus': 18960, 'discretionary': True, 'diff_hours': 0, 'diff': 235}, [0, 111325]), ('normal control', {'hours': 15, 'rate': 1913, 'bonus': 0, 'discretionary': False, 'diff_hours': 3, 'diff': 100}, [0, 28995]), ('normal control', {'hours': 42, 'rate': 2619, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [2619, 112617])], [('regression', {'hours': 55, 'rate': 3779, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [28343, 236188]), ('regression', {'hours': 45, 'rate': 1070, 'bonus': 6593, 'discretionary': True, 'diff_hours': 3, 'diff': 100}, [2692, 57735]), ('partial-repair probe', {'hours': 50, 'rate': 3473, 'bonus': 15335, 'discretionary': False, 'diff_hours': 14, 'diff': 0}, [18899, 207884]), ('partial-repair probe', {'hours': 49, 'rate': 2297, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [10337, 122890]), ('normal control', {'hours': 36, 'rate': 1564, 'bonus': 12440, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [0, 68744]), ('normal control', {'hours': 36, 'rate': 3124, 'bonus': 20788, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 133252]), ('normal control', {'hours': 38, 'rate': 3803, 'bonus': 0, 'discretionary': False, 'diff_hours': 5, 'diff': 175}, [0, 145389]), ('normal control', {'hours': 42, 'rate': 1092, 'bonus': 0, 'discretionary': False, 'diff_hours': 2, 'diff': 157}, [1099, 47277])], [('regression', {'hours': 50, 'rate': 3473, 'bonus': 15335, 'discretionary': False, 'diff_hours': 14, 'diff': 0}, [18899, 207884]), ('regression', {'hours': 60, 'rate': 3726, 'bonus': 328, 'discretionary': False, 'diff_hours': 13, 'diff': 0}, [37315, 261203]), ('partial-repair probe', {'hours': 59, 'rate': 1183, 'bonus': 15895, 'discretionary': True, 'diff_hours': 0, 'diff': 111}, [11239, 96931]), ('partial-repair probe', {'hours': 45, 'rate': 3152, 'bonus': 297, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [7897, 150034]), ('normal control', {'hours': 40, 'rate': 2368, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 0}, [0, 94720]), ('normal control', {'hours': 41, 'rate': 1070, 'bonus': 0, 'discretionary': False, 'diff_hours': 14, 'diff': 300}, [586, 48656]), ('normal control', {'hours': 15, 'rate': 1275, 'bonus': 16297, 'discretionary': False, 'diff_hours': 0, 'diff': 100}, [0, 35422]), ('normal control', {'hours': 0, 'rate': 1235, 'bonus': 452, 'discretionary': False, 'diff_hours': 15, 'diff': 0}, [0, 452])], [('regression', {'hours': 49, 'rate': 2297, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [10337, 122890]), ('regression', {'hours': 51, 'rate': 1430, 'bonus': 583, 'discretionary': True, 'diff_hours': 17, 'diff': 212}, [8254, 85371]), ('partial-repair probe', {'hours': 49, 'rate': 1393, 'bonus': 1015, 'discretionary': True, 'diff_hours': 13, 'diff': 0}, [6269, 75541]), ('partial-repair probe', {'hours': 41, 'rate': 3985, 'bonus': 0, 'discretionary': False, 'diff_hours': 0, 'diff': 218}, [1993, 165378]), ('normal control', {'hours': 25, 'rate': 2784, 'bonus': 431, 'discretionary': False, 'diff_hours': 0, 'diff': 150}, [0, 70031]), ('normal control', {'hours': 49, 'rate': 2740, 'bonus': 1615, 'discretionary': True, 'diff_hours': 20, 'diff': 0}, [12330, 148205]), ('normal control', {'hours': 4, 'rate': 2630, 'bonus': 24821, 'discretionary': False, 'diff_hours': 10, 'diff': 100}, [0, 36341]), ('normal control', {'hours': 36, 'rate': 3824, 'bonus': 0, 'discretionary': False, 'diff_hours': 12, 'diff': 100}, [0, 138864])], [('regression', {'hours': 59, 'rate': 1183, 'bonus': 15895, 'discretionary': True, 'diff_hours': 0, 'diff': 111}, [11239, 96931]), ('regression', {'hours': 41, 'rate': 1051, 'bonus': 26, 'discretionary': False, 'diff_hours': 0, 'diff': 259}, [526, 43643]), ('partial-repair probe', {'hours': 41, 'rate': 1613, 'bonus': 28839, 'discretionary': True, 'diff_hours': 0, 'diff': 100}, [807, 95779]), ('partial-repair probe', {'hours': 59, 'rate': 3943, 'bonus': 3183, 'discretionary': True, 'diff_hours': 0, 'diff': 50}, [37459, 273279]), ('normal control', {'hours': 51, 'rate': 3958, 'bonus': 443, 'discretionary': True, 'diff_hours': 0, 'diff': 100}, [21769, 224070]), ('normal control', {'hours': 36, 'rate': 3363, 'bonus': 0, 'discretionary': True, 'diff_hours': 0, 'diff': 0}, [0, 121068]), ('normal control', {'hours': 25, 'rate': 1555, 'bonus': 17670, 'discretionary': True, 'diff_hours': 0, 'diff': 150}, [0, 56545]), ('normal control', {'hours': 13, 'rate': 3420, 'bonus': 0, 'discretionary': True, 'diff_hours': 0, 'diff': 150}, [0, 44460])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression 0 | [11542, 85927] | [11543, 85928] | Failed |
| regression 1 | [9632, 125210] | [9632, 125210] | Passed |
| partial-repair probe 2 | [28342, 236187] | [28343, 236188] | Failed |
| partial-repair probe 3 | [18898, 207883] | [18899, 207884] | Failed |
| normal control 4 | [23692, 189536] | [23692, 189536] | Passed |
| normal control 5 | [0, 111325] | [0, 111325] | Passed |
| normal control 6 | [0, 28995] | [0, 28995] | Passed |
| normal control 7 | [2619, 112617] | [2619, 112617] | Passed |
SHA-256 / 6ca2712a93337ed2938117878eaca092f4b9d94ead7a67bf9e3abec529d5d6b7
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
A deterministic teaching model of a stipulated payroll rule with toy thresholds and rates. It makes no claim of conformance to any tax authority, statute or jurisdiction and is not payroll 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:32.112003+00:00.
Case digest / b836248ad479174e1867a4b701e81e60d79138ec985b9f2716c42f8f5b9f87de