FAILURE MAP
← Case archive

FA-76931 / Calendar recurrence rules / Open access

Monthly BYSETPOS selection from a weekday set: dup guard · case 01

BYSETPOS=1,-5 in a month with five candidates emits the same day twice.

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

ROOT CAUSE

Positions that resolve to the same candidate are both appended.

VERIFIED REPAIR

At the dup guard decision use `cand[idx] not in picked`, leaving the other decision sites of the model unchanged.

Unsuccessful approach: The partial repair `cand[idx] != (picked[-1] if picked else None)` only rejects a repeat of the most recently picked day.

Case contract

FREQ=MONTHLY;BYDAY=<weekdays>;BYSETPOS=<positions>. For each month from the dtstart month, the candidate set is every day of the whole month whose weekday is listed, in date order. Positions are 1-based, negative from the end; out-of-range positions are ignored and positions naming the same day yield it once. Selected days are emitted chronologically; days before dtstart are dropped after selection. Return the first count ISO dates.

Why this case matters

Recurring calendar series are expanded into concrete instances for display, reminders and conflict checks.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(dtstart, weekdays, setpos, count):
    start = dt.date.fromisoformat(dtstart)
    out = []
    for k in range(240):
        mi = start.month - 1 + k
        y, m = start.year + mi // 12, mi % 12 + 1
        dim = calendar.monthrange(y, m)[1]
        cand = [x for x in [dt.date(y, m, d) for d in range(1, dim + 1)] if x.weekday() in weekdays and x >= dt.date(y, m, 1)]
        picked = []
        for p in setpos:
            idx = p - 1 if p > 0 else len(cand) + p
            if 0 <= idx < len(cand) and True:
                picked.append(cand[idx])
        for d in sorted(picked):
            if d < start:
                continue
            out.append(d.isoformat())
            if len(out) >= count:
                return out
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: last weekday of month',
   ['2024-01-01', [0, 1, 2, 3, 4], [-1], 4],
   ['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']),
  ('first weekday, dtstart mid-month',
   ['2024-01-10', [0, 1, 2, 3, 4], [1], 3],
   ['2024-02-01', '2024-03-01', '2024-04-01']),
  ('first and last in reverse order',
   ['2024-03-01', [0, 1, 2, 3, 4], [-1, 1], 4],
   ['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']),
  ('coinciding positions',
   ['2024-01-01', [0], [1, -5], 4],
   ['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']),
  ('out of range negative', ['2024-01-01', [5, 6], [-7, 1], 3], ['2024-01-06', '2024-01-07', '2024-02-03']),
  ('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30'])],
 [('first and last in reverse order',
   ['2024-03-01', [0, 1, 2, 3, 4], [-1, 1], 4],
   ['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']),
  ('coinciding positions',
   ['2024-01-01', [0], [1, -5], 4],
   ['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']),
  ('out of range negative', ['2024-01-01', [5, 6], [-7, 1], 3], ['2024-01-06', '2024-01-07', '2024-02-03']),
  ('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30']),
  ('second weekend day', ['2024-06-15', [5, 6], [2], 3], ['2024-07-07', '2024-08-04', '2024-09-07']),
  ('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27'])],
 [('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']),
  ('out of range negative', ['2024-01-01', [5, 6], [-7, 1], 3], ['2024-01-06', '2024-01-07', '2024-02-03']),
  ('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30']),
  ('second weekend day', ['2024-06-15', [5, 6], [2], 3], ['2024-07-07', '2024-08-04', '2024-09-07']),
  ('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27']),
  ('position 3 of TU,TH mid month',
   ['2024-09-12', [1, 3], [3, -1], 4],
   ['2024-09-26', '2024-10-08', '2024-10-31', '2024-11-12']),
  ('december rollover',
   ['2024-12-01', [4], [1, -1], 4],
   ['2024-12-06', '2024-12-27', '2025-01-03', '2025-01-31'])],
 [('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30']),
  ('second weekend day', ['2024-06-15', [5, 6], [2], 3], ['2024-07-07', '2024-08-04', '2024-09-07']),
  ('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27']),
  ('position 3 of TU,TH mid month',
   ['2024-09-12', [1, 3], [3, -1], 4],
   ['2024-09-26', '2024-10-08', '2024-10-31', '2024-11-12']),
  ('december rollover',
   ['2024-12-01', [4], [1, -1], 4],
   ['2024-12-06', '2024-12-27', '2025-01-03', '2025-01-31']),
  ('dtstart equals picked day', ['2024-05-31', [0, 1, 2, 3, 4], [-1], 2], ['2024-05-31', '2024-06-28']),
  ('regression: last weekday of month',
   ['2024-01-01', [0, 1, 2, 3, 4], [-1], 4],
   ['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05'])],
 [('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27']),
  ('position 3 of TU,TH mid month',
   ['2024-09-12', [1, 3], [3, -1], 4],
   ['2024-09-26', '2024-10-08', '2024-10-31', '2024-11-12']),
  ('december rollover',
   ['2024-12-01', [4], [1, -1], 4],
   ['2024-12-06', '2024-12-27', '2025-01-03', '2025-01-31']),
  ('dtstart equals picked day', ['2024-05-31', [0, 1, 2, 3, 4], [-1], 2], ['2024-05-31', '2024-06-28']),
  ('regression: last weekday of month',
   ['2024-01-01', [0, 1, 2, 3, 4], [-1], 4],
   ['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']),
  ('first weekday, dtstart mid-month',
   ['2024-01-10', [0, 1, 2, 3, 4], [1], 3],
   ['2024-02-01', '2024-03-01', '2024-04-01']),
  ('first and last in reverse order',
   ['2024-03-01', [0, 1, 2, 3, 4], [-1, 1], 4],
   ['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']),
  ('coinciding positions',
   ['2024-01-01', [0], [1, -5], 4],
   ['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05'])]]
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
regression: last weekday of month['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']Passed
first weekday, dtstart mid-month['2024-02-01', '2024-03-01', '2024-04-01']['2024-02-01', '2024-03-01', '2024-04-01']Passed
first and last in reverse order['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']Passed
coinciding positions['2024-01-01', '2024-01-01', '2024-02-05', '2024-03-04']['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']Failed
three positions with repeat['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-01', '2024-05-29']['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']Failed
out of range negative['2024-01-06', '2024-01-07', '2024-02-03']['2024-01-06', '2024-01-07', '2024-02-03']Passed
out of range positive['2024-04-29', '2024-07-29', '2024-09-30']['2024-04-29', '2024-07-29', '2024-09-30']Passed

SHA-256 / c30ff03748231b9aa96ab7102c961165a679dabd05c30650fa17175fc06842c9

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(dtstart, weekdays, setpos, count):
    start = dt.date.fromisoformat(dtstart)
    out = []
    for k in range(240):
        mi = start.month - 1 + k
        y, m = start.year + mi // 12, mi % 12 + 1
        dim = calendar.monthrange(y, m)[1]
        cand = [x for x in [dt.date(y, m, d) for d in range(1, dim + 1)] if x.weekday() in weekdays and x >= dt.date(y, m, 1)]
        picked = []
        for p in setpos:
            idx = p - 1 if p > 0 else len(cand) + p
            if 0 <= idx < len(cand) and cand[idx] != (picked[-1] if picked else None):
                picked.append(cand[idx])
        for d in sorted(picked):
            if d < start:
                continue
            out.append(d.isoformat())
            if len(out) >= count:
                return out
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: last weekday of month',
   ['2024-01-01', [0, 1, 2, 3, 4], [-1], 4],
   ['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']),
  ('first weekday, dtstart mid-month',
   ['2024-01-10', [0, 1, 2, 3, 4], [1], 3],
   ['2024-02-01', '2024-03-01', '2024-04-01']),
  ('first and last in reverse order',
   ['2024-03-01', [0, 1, 2, 3, 4], [-1, 1], 4],
   ['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']),
  ('coinciding positions',
   ['2024-01-01', [0], [1, -5], 4],
   ['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']),
  ('out of range negative', ['2024-01-01', [5, 6], [-7, 1], 3], ['2024-01-06', '2024-01-07', '2024-02-03']),
  ('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30'])],
 [('first and last in reverse order',
   ['2024-03-01', [0, 1, 2, 3, 4], [-1, 1], 4],
   ['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']),
  ('coinciding positions',
   ['2024-01-01', [0], [1, -5], 4],
   ['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']),
  ('out of range negative', ['2024-01-01', [5, 6], [-7, 1], 3], ['2024-01-06', '2024-01-07', '2024-02-03']),
  ('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30']),
  ('second weekend day', ['2024-06-15', [5, 6], [2], 3], ['2024-07-07', '2024-08-04', '2024-09-07']),
  ('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27'])],
 [('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']),
  ('out of range negative', ['2024-01-01', [5, 6], [-7, 1], 3], ['2024-01-06', '2024-01-07', '2024-02-03']),
  ('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30']),
  ('second weekend day', ['2024-06-15', [5, 6], [2], 3], ['2024-07-07', '2024-08-04', '2024-09-07']),
  ('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27']),
  ('position 3 of TU,TH mid month',
   ['2024-09-12', [1, 3], [3, -1], 4],
   ['2024-09-26', '2024-10-08', '2024-10-31', '2024-11-12']),
  ('december rollover',
   ['2024-12-01', [4], [1, -1], 4],
   ['2024-12-06', '2024-12-27', '2025-01-03', '2025-01-31'])],
 [('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30']),
  ('second weekend day', ['2024-06-15', [5, 6], [2], 3], ['2024-07-07', '2024-08-04', '2024-09-07']),
  ('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27']),
  ('position 3 of TU,TH mid month',
   ['2024-09-12', [1, 3], [3, -1], 4],
   ['2024-09-26', '2024-10-08', '2024-10-31', '2024-11-12']),
  ('december rollover',
   ['2024-12-01', [4], [1, -1], 4],
   ['2024-12-06', '2024-12-27', '2025-01-03', '2025-01-31']),
  ('dtstart equals picked day', ['2024-05-31', [0, 1, 2, 3, 4], [-1], 2], ['2024-05-31', '2024-06-28']),
  ('regression: last weekday of month',
   ['2024-01-01', [0, 1, 2, 3, 4], [-1], 4],
   ['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05'])],
 [('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27']),
  ('position 3 of TU,TH mid month',
   ['2024-09-12', [1, 3], [3, -1], 4],
   ['2024-09-26', '2024-10-08', '2024-10-31', '2024-11-12']),
  ('december rollover',
   ['2024-12-01', [4], [1, -1], 4],
   ['2024-12-06', '2024-12-27', '2025-01-03', '2025-01-31']),
  ('dtstart equals picked day', ['2024-05-31', [0, 1, 2, 3, 4], [-1], 2], ['2024-05-31', '2024-06-28']),
  ('regression: last weekday of month',
   ['2024-01-01', [0, 1, 2, 3, 4], [-1], 4],
   ['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']),
  ('first weekday, dtstart mid-month',
   ['2024-01-10', [0, 1, 2, 3, 4], [1], 3],
   ['2024-02-01', '2024-03-01', '2024-04-01']),
  ('first and last in reverse order',
   ['2024-03-01', [0, 1, 2, 3, 4], [-1, 1], 4],
   ['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']),
  ('coinciding positions',
   ['2024-01-01', [0], [1, -5], 4],
   ['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05'])]]
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
regression: last weekday of month['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']Passed
first weekday, dtstart mid-month['2024-02-01', '2024-03-01', '2024-04-01']['2024-02-01', '2024-03-01', '2024-04-01']Passed
first and last in reverse order['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']Passed
coinciding positions['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']Passed
three positions with repeat['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-01', '2024-05-29']['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']Failed
out of range negative['2024-01-06', '2024-01-07', '2024-02-03']['2024-01-06', '2024-01-07', '2024-02-03']Passed
out of range positive['2024-04-29', '2024-07-29', '2024-09-30']['2024-04-29', '2024-07-29', '2024-09-30']Passed

SHA-256 / 3e90c326a7a92367e824ce0ee4972fe75d4ec030a4e5cf18e41484524c84f1c6

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import datetime as dt
import calendar
N = 1
observations = []
def solve(dtstart, weekdays, setpos, count):
    start = dt.date.fromisoformat(dtstart)
    out = []
    for k in range(240):
        mi = start.month - 1 + k
        y, m = start.year + mi // 12, mi % 12 + 1
        dim = calendar.monthrange(y, m)[1]
        cand = [x for x in [dt.date(y, m, d) for d in range(1, dim + 1)] if x.weekday() in weekdays and x >= dt.date(y, m, 1)]
        picked = []
        for p in setpos:
            idx = p - 1 if p > 0 else len(cand) + p
            if 0 <= idx < len(cand) and cand[idx] not in picked:
                picked.append(cand[idx])
        for d in sorted(picked):
            if d < start:
                continue
            out.append(d.isoformat())
            if len(out) >= count:
                return out
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: last weekday of month',
   ['2024-01-01', [0, 1, 2, 3, 4], [-1], 4],
   ['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']),
  ('first weekday, dtstart mid-month',
   ['2024-01-10', [0, 1, 2, 3, 4], [1], 3],
   ['2024-02-01', '2024-03-01', '2024-04-01']),
  ('first and last in reverse order',
   ['2024-03-01', [0, 1, 2, 3, 4], [-1, 1], 4],
   ['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']),
  ('coinciding positions',
   ['2024-01-01', [0], [1, -5], 4],
   ['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']),
  ('out of range negative', ['2024-01-01', [5, 6], [-7, 1], 3], ['2024-01-06', '2024-01-07', '2024-02-03']),
  ('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30'])],
 [('first and last in reverse order',
   ['2024-03-01', [0, 1, 2, 3, 4], [-1, 1], 4],
   ['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']),
  ('coinciding positions',
   ['2024-01-01', [0], [1, -5], 4],
   ['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']),
  ('out of range negative', ['2024-01-01', [5, 6], [-7, 1], 3], ['2024-01-06', '2024-01-07', '2024-02-03']),
  ('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30']),
  ('second weekend day', ['2024-06-15', [5, 6], [2], 3], ['2024-07-07', '2024-08-04', '2024-09-07']),
  ('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27'])],
 [('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']),
  ('out of range negative', ['2024-01-01', [5, 6], [-7, 1], 3], ['2024-01-06', '2024-01-07', '2024-02-03']),
  ('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30']),
  ('second weekend day', ['2024-06-15', [5, 6], [2], 3], ['2024-07-07', '2024-08-04', '2024-09-07']),
  ('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27']),
  ('position 3 of TU,TH mid month',
   ['2024-09-12', [1, 3], [3, -1], 4],
   ['2024-09-26', '2024-10-08', '2024-10-31', '2024-11-12']),
  ('december rollover',
   ['2024-12-01', [4], [1, -1], 4],
   ['2024-12-06', '2024-12-27', '2025-01-03', '2025-01-31'])],
 [('out of range positive', ['2024-02-01', [0], [5], 3], ['2024-04-29', '2024-07-29', '2024-09-30']),
  ('second weekend day', ['2024-06-15', [5, 6], [2], 3], ['2024-07-07', '2024-08-04', '2024-09-07']),
  ('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27']),
  ('position 3 of TU,TH mid month',
   ['2024-09-12', [1, 3], [3, -1], 4],
   ['2024-09-26', '2024-10-08', '2024-10-31', '2024-11-12']),
  ('december rollover',
   ['2024-12-01', [4], [1, -1], 4],
   ['2024-12-06', '2024-12-27', '2025-01-03', '2025-01-31']),
  ('dtstart equals picked day', ['2024-05-31', [0, 1, 2, 3, 4], [-1], 2], ['2024-05-31', '2024-06-28']),
  ('regression: last weekday of month',
   ['2024-01-01', [0, 1, 2, 3, 4], [-1], 4],
   ['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05'])],
 [('second to last weekday',
   ['2024-07-01', [0, 1, 2, 3, 4], [-2], 3],
   ['2024-07-30', '2024-08-29', '2024-09-27']),
  ('position 3 of TU,TH mid month',
   ['2024-09-12', [1, 3], [3, -1], 4],
   ['2024-09-26', '2024-10-08', '2024-10-31', '2024-11-12']),
  ('december rollover',
   ['2024-12-01', [4], [1, -1], 4],
   ['2024-12-06', '2024-12-27', '2025-01-03', '2025-01-31']),
  ('dtstart equals picked day', ['2024-05-31', [0, 1, 2, 3, 4], [-1], 2], ['2024-05-31', '2024-06-28']),
  ('regression: last weekday of month',
   ['2024-01-01', [0, 1, 2, 3, 4], [-1], 4],
   ['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']),
  ('first weekday, dtstart mid-month',
   ['2024-01-10', [0, 1, 2, 3, 4], [1], 3],
   ['2024-02-01', '2024-03-01', '2024-04-01']),
  ('first and last in reverse order',
   ['2024-03-01', [0, 1, 2, 3, 4], [-1, 1], 4],
   ['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']),
  ('coinciding positions',
   ['2024-01-01', [0], [1, -5], 4],
   ['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']),
  ('three positions with repeat',
   ['2024-04-01', [2], [1, -1, -5], 5],
   ['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05'])]]
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
regression: last weekday of month['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']['2024-01-31', '2024-02-29', '2024-03-29', '2024-04-30']Passed
first weekday, dtstart mid-month['2024-02-01', '2024-03-01', '2024-04-01']['2024-02-01', '2024-03-01', '2024-04-01']Passed
first and last in reverse order['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']['2024-03-01', '2024-03-29', '2024-04-01', '2024-04-30']Passed
coinciding positions['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']['2024-01-01', '2024-02-05', '2024-03-04', '2024-04-01']Passed
three positions with repeat['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']['2024-04-03', '2024-04-24', '2024-05-01', '2024-05-29', '2024-06-05']Passed
out of range negative['2024-01-06', '2024-01-07', '2024-02-03']['2024-01-06', '2024-01-07', '2024-02-03']Passed
out of range positive['2024-04-29', '2024-07-29', '2024-09-30']['2024-04-29', '2024-07-29', '2024-09-30']Passed

SHA-256 / 61c5314eafd4567bdb168e09f1a89eca0f56e7ecc2aca46570d477f2dc0e2d26

Verification & scope

Stipulated, bounded recurrence-expansion model evaluated offline on explicit fixtures; it is not a complete iCalendar implementation and makes no claim of standards conformance. 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:49:20.678240+00:00.

Case digest / ebde19cc71813f00ba80ba829ed5eee16b95dc275b97e335f4a84a54e2d3b76c