FAILURE MAP
← Case archive

FA-59226 / Payroll withholding rules / Open access

Pay dates in a calendar year: inclusive end count · case 01

Every year shows one pay date fewer than the payroll calendar.

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

ROOT CAUSE

The first pay date itself is not counted.

VERIFIED REPAIR

Restore the contract rule at the inclusive end count step: use `count = (hi - first).days // x['step'] + 1`.

Unsuccessful approach: The attempt adds the first date only when the span is not an exact multiple, dropping a pay date on December 31.

Case contract

Input {anchor [y,m,d] (any pay date), step 7|14 days, year}. Pay dates are anchor + k*step for all integers k. Return [count of pay dates within Jan 1..Dec 31 of year inclusive, ISO date of the first one, whether the count exceeds the nominal periods (26 biweekly, 52 weekly)].

Why this case matters

Annualization factors change in 27-pay-period years; missing or extra pay dates distort per-period withholding.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
    anchor = datetime.date(*x['anchor'])
    lo = datetime.date(x['year'], 1, 1)
    hi = datetime.date(x['year'], 12, 31)
    off = (lo - anchor).days
    k = -(-off // x['step'])
    first = anchor + datetime.timedelta(days=k * x['step'])
    count = (hi - first).days // x['step']
    periods = 26 if x['step'] == 14 else 52
    return [count, first.isoformat(), count > periods]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression (boundary)', {'anchor': [2026, 1, 1], 'step': 14, 'year': 2026}, [27, '2026-01-01', True]), ('regression (boundary)', {'anchor': [2020, 12, 31], 'step': 14, 'year': 2020}, [27, '2020-01-02', True]), ('partial-repair probe', {'anchor': [2021, 6, 20], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('partial-repair probe', {'anchor': [2021, 1, 17], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('additional oracle (boundary)', {'anchor': [2024, 1, 5], 'step': 14, 'year': 2024}, [26, '2024-01-05', False]), ('additional oracle', {'anchor': [2023, 8, 10], 'step': 14, 'year': 2024}, [26, '2024-01-11', False]), ('additional oracle', {'anchor': [2024, 3, 10], 'step': 14, 'year': 2024}, [26, '2024-01-14', False])], [('regression (boundary)', {'anchor': [2020, 12, 31], 'step': 14, 'year': 2020}, [27, '2020-01-02', True]), ('regression (boundary)', {'anchor': [2024, 1, 5], 'step': 14, 'year': 2024}, [26, '2024-01-05', False]), ('partial-repair probe', {'anchor': [2021, 6, 20], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('partial-repair probe', {'anchor': [2021, 1, 17], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('additional oracle', {'anchor': [2023, 8, 10], 'step': 14, 'year': 2024}, [26, '2024-01-11', False]), ('additional oracle', {'anchor': [2024, 3, 10], 'step': 14, 'year': 2024}, [26, '2024-01-14', False]), ('additional oracle', {'anchor': [2020, 3, 23], 'step': 14, 'year': 2020}, [26, '2020-01-13', False])], [('regression', {'anchor': [2021, 6, 20], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('regression (boundary)', {'anchor': [2024, 1, 5], 'step': 14, 'year': 2024}, [26, '2024-01-05', False]), ('partial-repair probe', {'anchor': [2022, 8, 16], 'step': 7, 'year': 2024}, [53, '2024-01-02', True]), ('partial-repair probe', {'anchor': [2025, 3, 13], 'step': 7, 'year': 2026}, [53, '2026-01-01', True]), ('additional oracle', {'anchor': [2023, 8, 10], 'step': 14, 'year': 2024}, [26, '2024-01-11', False]), ('additional oracle', {'anchor': [2024, 3, 10], 'step': 14, 'year': 2024}, [26, '2024-01-14', False]), ('additional oracle', {'anchor': [2020, 3, 23], 'step': 14, 'year': 2020}, [26, '2020-01-13', False])], [('regression', {'anchor': [2021, 1, 17], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('regression', {'anchor': [2023, 8, 10], 'step': 14, 'year': 2024}, [26, '2024-01-11', False]), ('partial-repair probe', {'anchor': [2020, 3, 26], 'step': 14, 'year': 2020}, [27, '2020-01-02', True]), ('partial-repair probe', {'anchor': [2024, 10, 27], 'step': 7, 'year': 2023}, [53, '2023-01-01', True]), ('additional oracle', {'anchor': [2024, 3, 10], 'step': 14, 'year': 2024}, [26, '2024-01-14', False]), ('additional oracle', {'anchor': [2020, 3, 23], 'step': 14, 'year': 2020}, [26, '2020-01-13', False]), ('additional oracle', {'anchor': [2019, 7, 21], 'step': 7, 'year': 2020}, [52, '2020-01-05', False])], [('regression', {'anchor': [2022, 8, 16], 'step': 7, 'year': 2024}, [53, '2024-01-02', True]), ('regression', {'anchor': [2024, 3, 10], 'step': 14, 'year': 2024}, [26, '2024-01-14', False]), ('partial-repair probe', {'anchor': [2023, 3, 28], 'step': 14, 'year': 2024}, [27, '2024-01-02', True]), ('partial-repair probe', {'anchor': [2021, 5, 2], 'step': 7, 'year': 2023}, [53, '2023-01-01', True]), ('additional oracle', {'anchor': [2020, 3, 23], 'step': 14, 'year': 2020}, [26, '2020-01-13', False]), ('additional oracle', {'anchor': [2019, 7, 21], 'step': 7, 'year': 2020}, [52, '2020-01-05', False]), ('additional oracle', {'anchor': [2021, 6, 11], 'step': 7, 'year': 2023}, [52, '2023-01-06', False])]]
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 (boundary) 0[26, '2026-01-01', False][27, '2026-01-01', True]Failed
regression (boundary) 1[26, '2020-01-02', False][27, '2020-01-02', True]Failed
partial-repair probe 2[26, '2023-01-01', False][27, '2023-01-01', True]Failed
partial-repair probe 3[26, '2023-01-01', False][27, '2023-01-01', True]Failed
additional oracle (boundary) 4[25, '2024-01-05', False][26, '2024-01-05', False]Failed
additional oracle 5[25, '2024-01-11', False][26, '2024-01-11', False]Failed
additional oracle 6[25, '2024-01-14', False][26, '2024-01-14', False]Failed

SHA-256 / d7654d496487da64e39f5a4c7d00465542463214d4d6fe2920a756f214dcfa70

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
    anchor = datetime.date(*x['anchor'])
    lo = datetime.date(x['year'], 1, 1)
    hi = datetime.date(x['year'], 12, 31)
    off = (lo - anchor).days
    k = -(-off // x['step'])
    first = anchor + datetime.timedelta(days=k * x['step'])
    count = (hi - first).days // x['step'] + (1 if (hi - first).days % x['step'] else 0)
    periods = 26 if x['step'] == 14 else 52
    return [count, first.isoformat(), count > periods]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression (boundary)', {'anchor': [2026, 1, 1], 'step': 14, 'year': 2026}, [27, '2026-01-01', True]), ('regression (boundary)', {'anchor': [2020, 12, 31], 'step': 14, 'year': 2020}, [27, '2020-01-02', True]), ('partial-repair probe', {'anchor': [2021, 6, 20], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('partial-repair probe', {'anchor': [2021, 1, 17], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('additional oracle (boundary)', {'anchor': [2024, 1, 5], 'step': 14, 'year': 2024}, [26, '2024-01-05', False]), ('additional oracle', {'anchor': [2023, 8, 10], 'step': 14, 'year': 2024}, [26, '2024-01-11', False]), ('additional oracle', {'anchor': [2024, 3, 10], 'step': 14, 'year': 2024}, [26, '2024-01-14', False])], [('regression (boundary)', {'anchor': [2020, 12, 31], 'step': 14, 'year': 2020}, [27, '2020-01-02', True]), ('regression (boundary)', {'anchor': [2024, 1, 5], 'step': 14, 'year': 2024}, [26, '2024-01-05', False]), ('partial-repair probe', {'anchor': [2021, 6, 20], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('partial-repair probe', {'anchor': [2021, 1, 17], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('additional oracle', {'anchor': [2023, 8, 10], 'step': 14, 'year': 2024}, [26, '2024-01-11', False]), ('additional oracle', {'anchor': [2024, 3, 10], 'step': 14, 'year': 2024}, [26, '2024-01-14', False]), ('additional oracle', {'anchor': [2020, 3, 23], 'step': 14, 'year': 2020}, [26, '2020-01-13', False])], [('regression', {'anchor': [2021, 6, 20], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('regression (boundary)', {'anchor': [2024, 1, 5], 'step': 14, 'year': 2024}, [26, '2024-01-05', False]), ('partial-repair probe', {'anchor': [2022, 8, 16], 'step': 7, 'year': 2024}, [53, '2024-01-02', True]), ('partial-repair probe', {'anchor': [2025, 3, 13], 'step': 7, 'year': 2026}, [53, '2026-01-01', True]), ('additional oracle', {'anchor': [2023, 8, 10], 'step': 14, 'year': 2024}, [26, '2024-01-11', False]), ('additional oracle', {'anchor': [2024, 3, 10], 'step': 14, 'year': 2024}, [26, '2024-01-14', False]), ('additional oracle', {'anchor': [2020, 3, 23], 'step': 14, 'year': 2020}, [26, '2020-01-13', False])], [('regression', {'anchor': [2021, 1, 17], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('regression', {'anchor': [2023, 8, 10], 'step': 14, 'year': 2024}, [26, '2024-01-11', False]), ('partial-repair probe', {'anchor': [2020, 3, 26], 'step': 14, 'year': 2020}, [27, '2020-01-02', True]), ('partial-repair probe', {'anchor': [2024, 10, 27], 'step': 7, 'year': 2023}, [53, '2023-01-01', True]), ('additional oracle', {'anchor': [2024, 3, 10], 'step': 14, 'year': 2024}, [26, '2024-01-14', False]), ('additional oracle', {'anchor': [2020, 3, 23], 'step': 14, 'year': 2020}, [26, '2020-01-13', False]), ('additional oracle', {'anchor': [2019, 7, 21], 'step': 7, 'year': 2020}, [52, '2020-01-05', False])], [('regression', {'anchor': [2022, 8, 16], 'step': 7, 'year': 2024}, [53, '2024-01-02', True]), ('regression', {'anchor': [2024, 3, 10], 'step': 14, 'year': 2024}, [26, '2024-01-14', False]), ('partial-repair probe', {'anchor': [2023, 3, 28], 'step': 14, 'year': 2024}, [27, '2024-01-02', True]), ('partial-repair probe', {'anchor': [2021, 5, 2], 'step': 7, 'year': 2023}, [53, '2023-01-01', True]), ('additional oracle', {'anchor': [2020, 3, 23], 'step': 14, 'year': 2020}, [26, '2020-01-13', False]), ('additional oracle', {'anchor': [2019, 7, 21], 'step': 7, 'year': 2020}, [52, '2020-01-05', False]), ('additional oracle', {'anchor': [2021, 6, 11], 'step': 7, 'year': 2023}, [52, '2023-01-06', False])]]
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 (boundary) 0[26, '2026-01-01', False][27, '2026-01-01', True]Failed
regression (boundary) 1[26, '2020-01-02', False][27, '2020-01-02', True]Failed
partial-repair probe 2[26, '2023-01-01', False][27, '2023-01-01', True]Failed
partial-repair probe 3[26, '2023-01-01', False][27, '2023-01-01', True]Failed
additional oracle (boundary) 4[26, '2024-01-05', False][26, '2024-01-05', False]Passed
additional oracle 5[26, '2024-01-11', False][26, '2024-01-11', False]Passed
additional oracle 6[26, '2024-01-14', False][26, '2024-01-14', False]Passed

SHA-256 / 98d4a20ba723ee7ee0bd067fb7a89394fb16798724edcdb8270ed339418c2b03

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime
N = 1
observations = []
def solve(x):
    anchor = datetime.date(*x['anchor'])
    lo = datetime.date(x['year'], 1, 1)
    hi = datetime.date(x['year'], 12, 31)
    off = (lo - anchor).days
    k = -(-off // x['step'])
    first = anchor + datetime.timedelta(days=k * x['step'])
    count = (hi - first).days // x['step'] + 1
    periods = 26 if x['step'] == 14 else 52
    return [count, first.isoformat(), count > periods]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression (boundary)', {'anchor': [2026, 1, 1], 'step': 14, 'year': 2026}, [27, '2026-01-01', True]), ('regression (boundary)', {'anchor': [2020, 12, 31], 'step': 14, 'year': 2020}, [27, '2020-01-02', True]), ('partial-repair probe', {'anchor': [2021, 6, 20], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('partial-repair probe', {'anchor': [2021, 1, 17], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('additional oracle (boundary)', {'anchor': [2024, 1, 5], 'step': 14, 'year': 2024}, [26, '2024-01-05', False]), ('additional oracle', {'anchor': [2023, 8, 10], 'step': 14, 'year': 2024}, [26, '2024-01-11', False]), ('additional oracle', {'anchor': [2024, 3, 10], 'step': 14, 'year': 2024}, [26, '2024-01-14', False])], [('regression (boundary)', {'anchor': [2020, 12, 31], 'step': 14, 'year': 2020}, [27, '2020-01-02', True]), ('regression (boundary)', {'anchor': [2024, 1, 5], 'step': 14, 'year': 2024}, [26, '2024-01-05', False]), ('partial-repair probe', {'anchor': [2021, 6, 20], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('partial-repair probe', {'anchor': [2021, 1, 17], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('additional oracle', {'anchor': [2023, 8, 10], 'step': 14, 'year': 2024}, [26, '2024-01-11', False]), ('additional oracle', {'anchor': [2024, 3, 10], 'step': 14, 'year': 2024}, [26, '2024-01-14', False]), ('additional oracle', {'anchor': [2020, 3, 23], 'step': 14, 'year': 2020}, [26, '2020-01-13', False])], [('regression', {'anchor': [2021, 6, 20], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('regression (boundary)', {'anchor': [2024, 1, 5], 'step': 14, 'year': 2024}, [26, '2024-01-05', False]), ('partial-repair probe', {'anchor': [2022, 8, 16], 'step': 7, 'year': 2024}, [53, '2024-01-02', True]), ('partial-repair probe', {'anchor': [2025, 3, 13], 'step': 7, 'year': 2026}, [53, '2026-01-01', True]), ('additional oracle', {'anchor': [2023, 8, 10], 'step': 14, 'year': 2024}, [26, '2024-01-11', False]), ('additional oracle', {'anchor': [2024, 3, 10], 'step': 14, 'year': 2024}, [26, '2024-01-14', False]), ('additional oracle', {'anchor': [2020, 3, 23], 'step': 14, 'year': 2020}, [26, '2020-01-13', False])], [('regression', {'anchor': [2021, 1, 17], 'step': 14, 'year': 2023}, [27, '2023-01-01', True]), ('regression', {'anchor': [2023, 8, 10], 'step': 14, 'year': 2024}, [26, '2024-01-11', False]), ('partial-repair probe', {'anchor': [2020, 3, 26], 'step': 14, 'year': 2020}, [27, '2020-01-02', True]), ('partial-repair probe', {'anchor': [2024, 10, 27], 'step': 7, 'year': 2023}, [53, '2023-01-01', True]), ('additional oracle', {'anchor': [2024, 3, 10], 'step': 14, 'year': 2024}, [26, '2024-01-14', False]), ('additional oracle', {'anchor': [2020, 3, 23], 'step': 14, 'year': 2020}, [26, '2020-01-13', False]), ('additional oracle', {'anchor': [2019, 7, 21], 'step': 7, 'year': 2020}, [52, '2020-01-05', False])], [('regression', {'anchor': [2022, 8, 16], 'step': 7, 'year': 2024}, [53, '2024-01-02', True]), ('regression', {'anchor': [2024, 3, 10], 'step': 14, 'year': 2024}, [26, '2024-01-14', False]), ('partial-repair probe', {'anchor': [2023, 3, 28], 'step': 14, 'year': 2024}, [27, '2024-01-02', True]), ('partial-repair probe', {'anchor': [2021, 5, 2], 'step': 7, 'year': 2023}, [53, '2023-01-01', True]), ('additional oracle', {'anchor': [2020, 3, 23], 'step': 14, 'year': 2020}, [26, '2020-01-13', False]), ('additional oracle', {'anchor': [2019, 7, 21], 'step': 7, 'year': 2020}, [52, '2020-01-05', False]), ('additional oracle', {'anchor': [2021, 6, 11], 'step': 7, 'year': 2023}, [52, '2023-01-06', False])]]
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 (boundary) 0[27, '2026-01-01', True][27, '2026-01-01', True]Passed
regression (boundary) 1[27, '2020-01-02', True][27, '2020-01-02', True]Passed
partial-repair probe 2[27, '2023-01-01', True][27, '2023-01-01', True]Passed
partial-repair probe 3[27, '2023-01-01', True][27, '2023-01-01', True]Passed
additional oracle (boundary) 4[26, '2024-01-05', False][26, '2024-01-05', False]Passed
additional oracle 5[26, '2024-01-11', False][26, '2024-01-11', False]Passed
additional oracle 6[26, '2024-01-14', False][26, '2024-01-14', False]Passed

SHA-256 / ac4e00a8207614bc7f510045225323c3aa147144fc61a7cf497187ff8cae14d7

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:34.213214+00:00.

Case digest / 439700be264dd82dfbd96aae482502944c485d4fc3d7fa47609e75f254a7748c