FAILURE MAP
← Case archive

FA-77246 / Calendar recurrence rules / Open access

Rendering a recurrence rule as a human-readable sentence: negative ordinal · case 01

BYDAY=-1FR is rendered as "the 1st to last Friday".

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

ROOT CAUSE

Every negative ordinal uses the "to last" form, including -1.

VERIFIED REPAIR

At the negative ordinal decision use `'last' if ordinal == -1 else nth(-ordinal) + ' to last'`, leaving the other decision sites of the model unchanged.

Unsuccessful approach: The partial repair `'last'` renders every negative ordinal as "last", so -2 loses its position.

Case contract

House style: "every <unit>" for interval 1, else "every <n> <unit>s"; weekday lists are in Monday-first order without duplicates and joined as "A, B and C"; the exact set MO..FR renders as "on weekdays"; an ordinal renders "on the 2nd Tuesday", -1 as "on the last Friday" and -n (n>1) as "on the 2nd to last Friday"; count renders ", once" for 1 and ", <n> times" otherwise.

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

N = 1
observations = []
def solve(freq, interval, byday, ordinal, count):
    unit = {'DAILY': 'day', 'WEEKLY': 'week', 'MONTHLY': 'month', 'YEARLY': 'year'}[freq]
    text = 'every ' + unit if interval == 1 else 'every %d %ss' % (interval, unit)
    names = {'MO': 'Monday', 'TU': 'Tuesday', 'WE': 'Wednesday', 'TH': 'Thursday', 'FR': 'Friday', 'SA': 'Saturday', 'SU': 'Sunday'}
    order = ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU']
    def nth(n):
        return str(n) + {1: 'st', 2: 'nd', 3: 'rd'}.get(n, 'th')
    if ordinal:
        word = (nth(-ordinal) + ' to last') if ordinal < 0 else nth(ordinal)
        text += ' on the ' + word + ' ' + names[byday[0]]
    elif byday:
        if set(byday) == {'MO', 'TU', 'WE', 'TH', 'FR'}:
            text += ' on weekdays'
        else:
            words = [names[d] for d in sorted(set(byday), key=order.index)]
            text += ' on ' + (words[0] if len(words) == 1 else ', '.join(words[:-1]) + ' and ' + words[-1])
    if count:
        text += ', ' + ('once' if count == 1 else '%d times' % count)
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: weekly three days',
   ['WEEKLY', 1, ['MO', 'WE', 'FR'], 0, 0],
   'every week on Monday, Wednesday and Friday'),
  ('biweekly single day once', ['WEEKLY', 2, ['TU'], 0, 1], 'every 2 weeks on Tuesday, once'),
  ('last friday monthly', ['MONTHLY', 1, ['FR'], -1, 6], 'every month on the last Friday, 6 times'),
  ('second to last sunday', ['MONTHLY', 3, ['SU'], -2, 0], 'every 3 months on the 2nd to last Sunday'),
  ('second tuesday', ['MONTHLY', 1, ['TU'], 2, 10], 'every month on the 2nd Tuesday, 10 times'),
  ('weekdays exact', ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'FR'], 0, 0], 'every week on weekdays'),
  ('weekdays reordered',
   ['WEEKLY', 1, ['FR', 'MO', 'TU', 'WE', 'TH'], 0, 3],
   'every week on weekdays, 3 times')],
 [('last friday monthly', ['MONTHLY', 1, ['FR'], -1, 6], 'every month on the last Friday, 6 times'),
  ('second to last sunday', ['MONTHLY', 3, ['SU'], -2, 0], 'every 3 months on the 2nd to last Sunday'),
  ('second tuesday', ['MONTHLY', 1, ['TU'], 2, 10], 'every month on the 2nd Tuesday, 10 times'),
  ('weekdays exact', ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'FR'], 0, 0], 'every week on weekdays'),
  ('weekdays reordered',
   ['WEEKLY', 1, ['FR', 'MO', 'TU', 'WE', 'TH'], 0, 3],
   'every week on weekdays, 3 times'),
  ('five days with saturday',
   ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'SA'], 0, 0],
   'every week on Monday, Tuesday, Wednesday, Thursday and Saturday'),
  ('duplicate days', ['WEEKLY', 3, ['SU', 'MO', 'SU'], 0, 2], 'every 3 weeks on Monday and Sunday, 2 times')],
 [('second tuesday', ['MONTHLY', 1, ['TU'], 2, 10], 'every month on the 2nd Tuesday, 10 times'),
  ('weekdays exact', ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'FR'], 0, 0], 'every week on weekdays'),
  ('weekdays reordered',
   ['WEEKLY', 1, ['FR', 'MO', 'TU', 'WE', 'TH'], 0, 3],
   'every week on weekdays, 3 times'),
  ('five days with saturday',
   ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'SA'], 0, 0],
   'every week on Monday, Tuesday, Wednesday, Thursday and Saturday'),
  ('duplicate days', ['WEEKLY', 3, ['SU', 'MO', 'SU'], 0, 2], 'every 3 weeks on Monday and Sunday, 2 times'),
  ('daily with count one', ['DAILY', 1, [], 0, 1], 'every day, once'),
  ('yearly interval', ['YEARLY', 4, [], 0, 0], 'every 4 years'),
  ('last friday monthly', ['MONTHLY', 1, ['FR'], -1, 6], 'every month on the last Friday, 6 times'),
  ('second to last sunday', ['MONTHLY', 3, ['SU'], -2, 0], 'every 3 months on the 2nd to last Sunday')],
 [('weekdays reordered',
   ['WEEKLY', 1, ['FR', 'MO', 'TU', 'WE', 'TH'], 0, 3],
   'every week on weekdays, 3 times'),
  ('five days with saturday',
   ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'SA'], 0, 0],
   'every week on Monday, Tuesday, Wednesday, Thursday and Saturday'),
  ('duplicate days', ['WEEKLY', 3, ['SU', 'MO', 'SU'], 0, 2], 'every 3 weeks on Monday and Sunday, 2 times'),
  ('daily with count one', ['DAILY', 1, [], 0, 1], 'every day, once'),
  ('yearly interval', ['YEARLY', 4, [], 0, 0], 'every 4 years'),
  ('two days unordered', ['WEEKLY', 1, ['TH', 'TU'], 0, 1], 'every week on Tuesday and Thursday, once'),
  ('regression: weekly three days',
   ['WEEKLY', 1, ['MO', 'WE', 'FR'], 0, 0],
   'every week on Monday, Wednesday and Friday'),
  ('last friday monthly', ['MONTHLY', 1, ['FR'], -1, 6], 'every month on the last Friday, 6 times'),
  ('second to last sunday', ['MONTHLY', 3, ['SU'], -2, 0], 'every 3 months on the 2nd to last Sunday')],
 [('duplicate days', ['WEEKLY', 3, ['SU', 'MO', 'SU'], 0, 2], 'every 3 weeks on Monday and Sunday, 2 times'),
  ('daily with count one', ['DAILY', 1, [], 0, 1], 'every day, once'),
  ('yearly interval', ['YEARLY', 4, [], 0, 0], 'every 4 years'),
  ('two days unordered', ['WEEKLY', 1, ['TH', 'TU'], 0, 1], 'every week on Tuesday and Thursday, once'),
  ('regression: weekly three days',
   ['WEEKLY', 1, ['MO', 'WE', 'FR'], 0, 0],
   'every week on Monday, Wednesday and Friday'),
  ('biweekly single day once', ['WEEKLY', 2, ['TU'], 0, 1], 'every 2 weeks on Tuesday, once'),
  ('last friday monthly', ['MONTHLY', 1, ['FR'], -1, 6], 'every month on the last Friday, 6 times'),
  ('second to last sunday', ['MONTHLY', 3, ['SU'], -2, 0], 'every 3 months on the 2nd to last Sunday')]]
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: weekly three daysevery week on Monday, Wednesday and Fridayevery week on Monday, Wednesday and FridayPassed
biweekly single day onceevery 2 weeks on Tuesday, onceevery 2 weeks on Tuesday, oncePassed
last friday monthlyevery month on the 1st to last Friday, 6 timesevery month on the last Friday, 6 timesFailed
second to last sundayevery 3 months on the 2nd to last Sundayevery 3 months on the 2nd to last SundayPassed
second tuesdayevery month on the 2nd Tuesday, 10 timesevery month on the 2nd Tuesday, 10 timesPassed
weekdays exactevery week on weekdaysevery week on weekdaysPassed
weekdays reorderedevery week on weekdays, 3 timesevery week on weekdays, 3 timesPassed

SHA-256 / 1427b5e6afae94c8742609456305da21885de916c374207fb4f51538bf00f46c

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(freq, interval, byday, ordinal, count):
    unit = {'DAILY': 'day', 'WEEKLY': 'week', 'MONTHLY': 'month', 'YEARLY': 'year'}[freq]
    text = 'every ' + unit if interval == 1 else 'every %d %ss' % (interval, unit)
    names = {'MO': 'Monday', 'TU': 'Tuesday', 'WE': 'Wednesday', 'TH': 'Thursday', 'FR': 'Friday', 'SA': 'Saturday', 'SU': 'Sunday'}
    order = ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU']
    def nth(n):
        return str(n) + {1: 'st', 2: 'nd', 3: 'rd'}.get(n, 'th')
    if ordinal:
        word = ('last') if ordinal < 0 else nth(ordinal)
        text += ' on the ' + word + ' ' + names[byday[0]]
    elif byday:
        if set(byday) == {'MO', 'TU', 'WE', 'TH', 'FR'}:
            text += ' on weekdays'
        else:
            words = [names[d] for d in sorted(set(byday), key=order.index)]
            text += ' on ' + (words[0] if len(words) == 1 else ', '.join(words[:-1]) + ' and ' + words[-1])
    if count:
        text += ', ' + ('once' if count == 1 else '%d times' % count)
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: weekly three days',
   ['WEEKLY', 1, ['MO', 'WE', 'FR'], 0, 0],
   'every week on Monday, Wednesday and Friday'),
  ('biweekly single day once', ['WEEKLY', 2, ['TU'], 0, 1], 'every 2 weeks on Tuesday, once'),
  ('last friday monthly', ['MONTHLY', 1, ['FR'], -1, 6], 'every month on the last Friday, 6 times'),
  ('second to last sunday', ['MONTHLY', 3, ['SU'], -2, 0], 'every 3 months on the 2nd to last Sunday'),
  ('second tuesday', ['MONTHLY', 1, ['TU'], 2, 10], 'every month on the 2nd Tuesday, 10 times'),
  ('weekdays exact', ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'FR'], 0, 0], 'every week on weekdays'),
  ('weekdays reordered',
   ['WEEKLY', 1, ['FR', 'MO', 'TU', 'WE', 'TH'], 0, 3],
   'every week on weekdays, 3 times')],
 [('last friday monthly', ['MONTHLY', 1, ['FR'], -1, 6], 'every month on the last Friday, 6 times'),
  ('second to last sunday', ['MONTHLY', 3, ['SU'], -2, 0], 'every 3 months on the 2nd to last Sunday'),
  ('second tuesday', ['MONTHLY', 1, ['TU'], 2, 10], 'every month on the 2nd Tuesday, 10 times'),
  ('weekdays exact', ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'FR'], 0, 0], 'every week on weekdays'),
  ('weekdays reordered',
   ['WEEKLY', 1, ['FR', 'MO', 'TU', 'WE', 'TH'], 0, 3],
   'every week on weekdays, 3 times'),
  ('five days with saturday',
   ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'SA'], 0, 0],
   'every week on Monday, Tuesday, Wednesday, Thursday and Saturday'),
  ('duplicate days', ['WEEKLY', 3, ['SU', 'MO', 'SU'], 0, 2], 'every 3 weeks on Monday and Sunday, 2 times')],
 [('second tuesday', ['MONTHLY', 1, ['TU'], 2, 10], 'every month on the 2nd Tuesday, 10 times'),
  ('weekdays exact', ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'FR'], 0, 0], 'every week on weekdays'),
  ('weekdays reordered',
   ['WEEKLY', 1, ['FR', 'MO', 'TU', 'WE', 'TH'], 0, 3],
   'every week on weekdays, 3 times'),
  ('five days with saturday',
   ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'SA'], 0, 0],
   'every week on Monday, Tuesday, Wednesday, Thursday and Saturday'),
  ('duplicate days', ['WEEKLY', 3, ['SU', 'MO', 'SU'], 0, 2], 'every 3 weeks on Monday and Sunday, 2 times'),
  ('daily with count one', ['DAILY', 1, [], 0, 1], 'every day, once'),
  ('yearly interval', ['YEARLY', 4, [], 0, 0], 'every 4 years'),
  ('last friday monthly', ['MONTHLY', 1, ['FR'], -1, 6], 'every month on the last Friday, 6 times'),
  ('second to last sunday', ['MONTHLY', 3, ['SU'], -2, 0], 'every 3 months on the 2nd to last Sunday')],
 [('weekdays reordered',
   ['WEEKLY', 1, ['FR', 'MO', 'TU', 'WE', 'TH'], 0, 3],
   'every week on weekdays, 3 times'),
  ('five days with saturday',
   ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'SA'], 0, 0],
   'every week on Monday, Tuesday, Wednesday, Thursday and Saturday'),
  ('duplicate days', ['WEEKLY', 3, ['SU', 'MO', 'SU'], 0, 2], 'every 3 weeks on Monday and Sunday, 2 times'),
  ('daily with count one', ['DAILY', 1, [], 0, 1], 'every day, once'),
  ('yearly interval', ['YEARLY', 4, [], 0, 0], 'every 4 years'),
  ('two days unordered', ['WEEKLY', 1, ['TH', 'TU'], 0, 1], 'every week on Tuesday and Thursday, once'),
  ('regression: weekly three days',
   ['WEEKLY', 1, ['MO', 'WE', 'FR'], 0, 0],
   'every week on Monday, Wednesday and Friday'),
  ('last friday monthly', ['MONTHLY', 1, ['FR'], -1, 6], 'every month on the last Friday, 6 times'),
  ('second to last sunday', ['MONTHLY', 3, ['SU'], -2, 0], 'every 3 months on the 2nd to last Sunday')],
 [('duplicate days', ['WEEKLY', 3, ['SU', 'MO', 'SU'], 0, 2], 'every 3 weeks on Monday and Sunday, 2 times'),
  ('daily with count one', ['DAILY', 1, [], 0, 1], 'every day, once'),
  ('yearly interval', ['YEARLY', 4, [], 0, 0], 'every 4 years'),
  ('two days unordered', ['WEEKLY', 1, ['TH', 'TU'], 0, 1], 'every week on Tuesday and Thursday, once'),
  ('regression: weekly three days',
   ['WEEKLY', 1, ['MO', 'WE', 'FR'], 0, 0],
   'every week on Monday, Wednesday and Friday'),
  ('biweekly single day once', ['WEEKLY', 2, ['TU'], 0, 1], 'every 2 weeks on Tuesday, once'),
  ('last friday monthly', ['MONTHLY', 1, ['FR'], -1, 6], 'every month on the last Friday, 6 times'),
  ('second to last sunday', ['MONTHLY', 3, ['SU'], -2, 0], 'every 3 months on the 2nd to last Sunday')]]
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: weekly three daysevery week on Monday, Wednesday and Fridayevery week on Monday, Wednesday and FridayPassed
biweekly single day onceevery 2 weeks on Tuesday, onceevery 2 weeks on Tuesday, oncePassed
last friday monthlyevery month on the last Friday, 6 timesevery month on the last Friday, 6 timesPassed
second to last sundayevery 3 months on the last Sundayevery 3 months on the 2nd to last SundayFailed
second tuesdayevery month on the 2nd Tuesday, 10 timesevery month on the 2nd Tuesday, 10 timesPassed
weekdays exactevery week on weekdaysevery week on weekdaysPassed
weekdays reorderedevery week on weekdays, 3 timesevery week on weekdays, 3 timesPassed

SHA-256 / fc732bbb83b73eb5129fb81608e61d839153b6039c313bc1affe95f950fdb85d

3 / The verified repair

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

N = 1
observations = []
def solve(freq, interval, byday, ordinal, count):
    unit = {'DAILY': 'day', 'WEEKLY': 'week', 'MONTHLY': 'month', 'YEARLY': 'year'}[freq]
    text = 'every ' + unit if interval == 1 else 'every %d %ss' % (interval, unit)
    names = {'MO': 'Monday', 'TU': 'Tuesday', 'WE': 'Wednesday', 'TH': 'Thursday', 'FR': 'Friday', 'SA': 'Saturday', 'SU': 'Sunday'}
    order = ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU']
    def nth(n):
        return str(n) + {1: 'st', 2: 'nd', 3: 'rd'}.get(n, 'th')
    if ordinal:
        word = ('last' if ordinal == -1 else nth(-ordinal) + ' to last') if ordinal < 0 else nth(ordinal)
        text += ' on the ' + word + ' ' + names[byday[0]]
    elif byday:
        if set(byday) == {'MO', 'TU', 'WE', 'TH', 'FR'}:
            text += ' on weekdays'
        else:
            words = [names[d] for d in sorted(set(byday), key=order.index)]
            text += ' on ' + (words[0] if len(words) == 1 else ', '.join(words[:-1]) + ' and ' + words[-1])
    if count:
        text += ', ' + ('once' if count == 1 else '%d times' % count)
    return text
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: weekly three days',
   ['WEEKLY', 1, ['MO', 'WE', 'FR'], 0, 0],
   'every week on Monday, Wednesday and Friday'),
  ('biweekly single day once', ['WEEKLY', 2, ['TU'], 0, 1], 'every 2 weeks on Tuesday, once'),
  ('last friday monthly', ['MONTHLY', 1, ['FR'], -1, 6], 'every month on the last Friday, 6 times'),
  ('second to last sunday', ['MONTHLY', 3, ['SU'], -2, 0], 'every 3 months on the 2nd to last Sunday'),
  ('second tuesday', ['MONTHLY', 1, ['TU'], 2, 10], 'every month on the 2nd Tuesday, 10 times'),
  ('weekdays exact', ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'FR'], 0, 0], 'every week on weekdays'),
  ('weekdays reordered',
   ['WEEKLY', 1, ['FR', 'MO', 'TU', 'WE', 'TH'], 0, 3],
   'every week on weekdays, 3 times')],
 [('last friday monthly', ['MONTHLY', 1, ['FR'], -1, 6], 'every month on the last Friday, 6 times'),
  ('second to last sunday', ['MONTHLY', 3, ['SU'], -2, 0], 'every 3 months on the 2nd to last Sunday'),
  ('second tuesday', ['MONTHLY', 1, ['TU'], 2, 10], 'every month on the 2nd Tuesday, 10 times'),
  ('weekdays exact', ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'FR'], 0, 0], 'every week on weekdays'),
  ('weekdays reordered',
   ['WEEKLY', 1, ['FR', 'MO', 'TU', 'WE', 'TH'], 0, 3],
   'every week on weekdays, 3 times'),
  ('five days with saturday',
   ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'SA'], 0, 0],
   'every week on Monday, Tuesday, Wednesday, Thursday and Saturday'),
  ('duplicate days', ['WEEKLY', 3, ['SU', 'MO', 'SU'], 0, 2], 'every 3 weeks on Monday and Sunday, 2 times')],
 [('second tuesday', ['MONTHLY', 1, ['TU'], 2, 10], 'every month on the 2nd Tuesday, 10 times'),
  ('weekdays exact', ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'FR'], 0, 0], 'every week on weekdays'),
  ('weekdays reordered',
   ['WEEKLY', 1, ['FR', 'MO', 'TU', 'WE', 'TH'], 0, 3],
   'every week on weekdays, 3 times'),
  ('five days with saturday',
   ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'SA'], 0, 0],
   'every week on Monday, Tuesday, Wednesday, Thursday and Saturday'),
  ('duplicate days', ['WEEKLY', 3, ['SU', 'MO', 'SU'], 0, 2], 'every 3 weeks on Monday and Sunday, 2 times'),
  ('daily with count one', ['DAILY', 1, [], 0, 1], 'every day, once'),
  ('yearly interval', ['YEARLY', 4, [], 0, 0], 'every 4 years'),
  ('last friday monthly', ['MONTHLY', 1, ['FR'], -1, 6], 'every month on the last Friday, 6 times'),
  ('second to last sunday', ['MONTHLY', 3, ['SU'], -2, 0], 'every 3 months on the 2nd to last Sunday')],
 [('weekdays reordered',
   ['WEEKLY', 1, ['FR', 'MO', 'TU', 'WE', 'TH'], 0, 3],
   'every week on weekdays, 3 times'),
  ('five days with saturday',
   ['WEEKLY', 1, ['MO', 'TU', 'WE', 'TH', 'SA'], 0, 0],
   'every week on Monday, Tuesday, Wednesday, Thursday and Saturday'),
  ('duplicate days', ['WEEKLY', 3, ['SU', 'MO', 'SU'], 0, 2], 'every 3 weeks on Monday and Sunday, 2 times'),
  ('daily with count one', ['DAILY', 1, [], 0, 1], 'every day, once'),
  ('yearly interval', ['YEARLY', 4, [], 0, 0], 'every 4 years'),
  ('two days unordered', ['WEEKLY', 1, ['TH', 'TU'], 0, 1], 'every week on Tuesday and Thursday, once'),
  ('regression: weekly three days',
   ['WEEKLY', 1, ['MO', 'WE', 'FR'], 0, 0],
   'every week on Monday, Wednesday and Friday'),
  ('last friday monthly', ['MONTHLY', 1, ['FR'], -1, 6], 'every month on the last Friday, 6 times'),
  ('second to last sunday', ['MONTHLY', 3, ['SU'], -2, 0], 'every 3 months on the 2nd to last Sunday')],
 [('duplicate days', ['WEEKLY', 3, ['SU', 'MO', 'SU'], 0, 2], 'every 3 weeks on Monday and Sunday, 2 times'),
  ('daily with count one', ['DAILY', 1, [], 0, 1], 'every day, once'),
  ('yearly interval', ['YEARLY', 4, [], 0, 0], 'every 4 years'),
  ('two days unordered', ['WEEKLY', 1, ['TH', 'TU'], 0, 1], 'every week on Tuesday and Thursday, once'),
  ('regression: weekly three days',
   ['WEEKLY', 1, ['MO', 'WE', 'FR'], 0, 0],
   'every week on Monday, Wednesday and Friday'),
  ('biweekly single day once', ['WEEKLY', 2, ['TU'], 0, 1], 'every 2 weeks on Tuesday, once'),
  ('last friday monthly', ['MONTHLY', 1, ['FR'], -1, 6], 'every month on the last Friday, 6 times'),
  ('second to last sunday', ['MONTHLY', 3, ['SU'], -2, 0], 'every 3 months on the 2nd to last Sunday')]]
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: weekly three daysevery week on Monday, Wednesday and Fridayevery week on Monday, Wednesday and FridayPassed
biweekly single day onceevery 2 weeks on Tuesday, onceevery 2 weeks on Tuesday, oncePassed
last friday monthlyevery month on the last Friday, 6 timesevery month on the last Friday, 6 timesPassed
second to last sundayevery 3 months on the 2nd to last Sundayevery 3 months on the 2nd to last SundayPassed
second tuesdayevery month on the 2nd Tuesday, 10 timesevery month on the 2nd Tuesday, 10 timesPassed
weekdays exactevery week on weekdaysevery week on weekdaysPassed
weekdays reorderedevery week on weekdays, 3 timesevery week on weekdays, 3 timesPassed

SHA-256 / 7d3a5ca99c02404df8596d41dfc18685fb6e485bd708f90723cb6f31d0b24e59

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

Case digest / afeb1ea45da2f3a1e50e328d194f72ff71cbe07a780b7fb36833d7224fa76393