FA-76991 / Calendar recurrence rules / Open access
Applying moved and cancelled instance overrides in a window query: override order · case 01
Of two overrides for the same instance, the earlier edit wins.
ROOT CAUSE
Overrides are sorted by target date before application, destroying edit order.
VERIFIED REPAIR
At the override order decision use `overrides`, leaving the other decision sites of the model unchanged.
Unsuccessful approach: The partial repair `reversed(overrides)` reverses the edit order, making the first edit win.
Case contract
A daily-interval series of count instances. overrides is an ordered list of [original_date, new_date] where new_date None cancels; for repeated originals the last override wins; overrides whose original is not a series instance are ignored. Return [original, actual] pairs for instances whose actual date lies in [window_start, window_end], sorted by actual then original date.
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, interval, count, overrides, window_start, window_end):
start = dt.date.fromisoformat(dtstart)
ws = dt.date.fromisoformat(window_start)
we = dt.date.fromisoformat(window_end)
originals = [start + dt.timedelta(days=k * interval) for k in range(count)]
origset = set(originals)
actual = {o: o for o in originals}
for orig, new in sorted(overrides, key=lambda p: p[1] or ''):
o = dt.date.fromisoformat(orig)
if o not in origset:
continue
actual[o] = None if new is None else dt.date.fromisoformat(new)
rows = [[o.isoformat(), a.isoformat()] for o, a in actual.items() if a is not None and ws <= a <= we]
return sorted(rows, key=lambda r: (r[1], r[0]))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: moved into window',
['2024-01-01', 1, 10, [['2024-01-02', '2024-01-06']], '2024-01-05', '2024-01-07'],
[['2024-01-05', '2024-01-05'],
['2024-01-02', '2024-01-06'],
['2024-01-06', '2024-01-06'],
['2024-01-07', '2024-01-07']]),
('moved out of window',
['2024-01-01', 1, 10, [['2024-01-06', '2024-01-20']], '2024-01-05', '2024-01-07'],
[['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07']]),
('cancelled instance',
['2024-01-01', 2, 5, [['2024-01-03', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'],
['2024-01-05', '2024-01-05'],
['2024-01-07', '2024-01-07'],
['2024-01-09', '2024-01-09']]),
('orphan move',
['2024-01-01', 2, 5, [['2024-01-02', '2024-01-04']], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'],
['2024-01-03', '2024-01-03'],
['2024-01-05', '2024-01-05'],
['2024-01-07', '2024-01-07'],
['2024-01-09', '2024-01-09']]),
('orphan cancel',
['2024-01-01', 2, 3, [['2024-01-04', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05']]),
('last override wins',
['2024-02-01',
1,
4,
[['2024-02-02', '2024-02-10'], ['2024-02-02', '2024-02-03']],
'2024-02-01',
'2024-02-10'],
[['2024-02-01', '2024-02-01'],
['2024-02-02', '2024-02-03'],
['2024-02-03', '2024-02-03'],
['2024-02-04', '2024-02-04']]),
('cancel then move',
['2024-02-01', 1, 3, [['2024-02-02', None], ['2024-02-02', '2024-02-05']], '2024-02-01', '2024-02-05'],
[['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']])],
[('cancelled instance',
['2024-01-01', 2, 5, [['2024-01-03', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'],
['2024-01-05', '2024-01-05'],
['2024-01-07', '2024-01-07'],
['2024-01-09', '2024-01-09']]),
('orphan move',
['2024-01-01', 2, 5, [['2024-01-02', '2024-01-04']], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'],
['2024-01-03', '2024-01-03'],
['2024-01-05', '2024-01-05'],
['2024-01-07', '2024-01-07'],
['2024-01-09', '2024-01-09']]),
('orphan cancel',
['2024-01-01', 2, 3, [['2024-01-04', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05']]),
('last override wins',
['2024-02-01',
1,
4,
[['2024-02-02', '2024-02-10'], ['2024-02-02', '2024-02-03']],
'2024-02-01',
'2024-02-10'],
[['2024-02-01', '2024-02-01'],
['2024-02-02', '2024-02-03'],
['2024-02-03', '2024-02-03'],
['2024-02-04', '2024-02-04']]),
('cancel then move',
['2024-02-01', 1, 3, [['2024-02-02', None], ['2024-02-02', '2024-02-05']], '2024-02-01', '2024-02-05'],
[['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']]),
('restated original date',
['2024-03-01', 7, 3, [['2024-03-08', '2024-03-08']], '2024-03-01', '2024-03-31'],
[['2024-03-01', '2024-03-01'], ['2024-03-08', '2024-03-08'], ['2024-03-15', '2024-03-15']]),
('two moved onto same day',
['2024-04-01',
1,
5,
[['2024-04-04', '2024-04-02'], ['2024-04-05', '2024-04-02']],
'2024-04-02',
'2024-04-03'],
[['2024-04-02', '2024-04-02'],
['2024-04-04', '2024-04-02'],
['2024-04-05', '2024-04-02'],
['2024-04-03', '2024-04-03']])],
[('orphan cancel',
['2024-01-01', 2, 3, [['2024-01-04', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05']]),
('last override wins',
['2024-02-01',
1,
4,
[['2024-02-02', '2024-02-10'], ['2024-02-02', '2024-02-03']],
'2024-02-01',
'2024-02-10'],
[['2024-02-01', '2024-02-01'],
['2024-02-02', '2024-02-03'],
['2024-02-03', '2024-02-03'],
['2024-02-04', '2024-02-04']]),
('cancel then move',
['2024-02-01', 1, 3, [['2024-02-02', None], ['2024-02-02', '2024-02-05']], '2024-02-01', '2024-02-05'],
[['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']]),
('restated original date',
['2024-03-01', 7, 3, [['2024-03-08', '2024-03-08']], '2024-03-01', '2024-03-31'],
[['2024-03-01', '2024-03-01'], ['2024-03-08', '2024-03-08'], ['2024-03-15', '2024-03-15']]),
('two moved onto same day',
['2024-04-01',
1,
5,
[['2024-04-04', '2024-04-02'], ['2024-04-05', '2024-04-02']],
'2024-04-02',
'2024-04-03'],
[['2024-04-02', '2024-04-02'],
['2024-04-04', '2024-04-02'],
['2024-04-05', '2024-04-02'],
['2024-04-03', '2024-04-03']]),
('orphan after series end',
['2024-05-01', 1, 3, [['2024-05-10', '2024-05-02']], '2024-05-01', '2024-05-10'],
[['2024-05-01', '2024-05-01'], ['2024-05-02', '2024-05-02'], ['2024-05-03', '2024-05-03']]),
('move then cancel',
['2024-06-01', 1, 3, [['2024-06-03', '2024-06-01'], ['2024-06-03', None]], '2024-06-01', '2024-06-05'],
[['2024-06-01', '2024-06-01'], ['2024-06-02', '2024-06-02']])],
[('cancel then move',
['2024-02-01', 1, 3, [['2024-02-02', None], ['2024-02-02', '2024-02-05']], '2024-02-01', '2024-02-05'],
[['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']]),
('restated original date',
['2024-03-01', 7, 3, [['2024-03-08', '2024-03-08']], '2024-03-01', '2024-03-31'],
[['2024-03-01', '2024-03-01'], ['2024-03-08', '2024-03-08'], ['2024-03-15', '2024-03-15']]),
('two moved onto same day',
['2024-04-01',
1,
5,
[['2024-04-04', '2024-04-02'], ['2024-04-05', '2024-04-02']],
'2024-04-02',
'2024-04-03'],
[['2024-04-02', '2024-04-02'],
['2024-04-04', '2024-04-02'],
['2024-04-05', '2024-04-02'],
['2024-04-03', '2024-04-03']]),
('orphan after series end',
['2024-05-01', 1, 3, [['2024-05-10', '2024-05-02']], '2024-05-01', '2024-05-10'],
[['2024-05-01', '2024-05-01'], ['2024-05-02', '2024-05-02'], ['2024-05-03', '2024-05-03']]),
('move then cancel',
['2024-06-01', 1, 3, [['2024-06-03', '2024-06-01'], ['2024-06-03', None]], '2024-06-01', '2024-06-05'],
[['2024-06-01', '2024-06-01'], ['2024-06-02', '2024-06-02']]),
('no overrides',
['2024-06-01', 3, 3, [], '2024-06-02', '2024-06-07'],
[['2024-06-04', '2024-06-04'], ['2024-06-07', '2024-06-07']]),
('regression: moved into window',
['2024-01-01', 1, 10, [['2024-01-02', '2024-01-06']], '2024-01-05', '2024-01-07'],
[['2024-01-05', '2024-01-05'],
['2024-01-02', '2024-01-06'],
['2024-01-06', '2024-01-06'],
['2024-01-07', '2024-01-07']])],
[('two moved onto same day',
['2024-04-01',
1,
5,
[['2024-04-04', '2024-04-02'], ['2024-04-05', '2024-04-02']],
'2024-04-02',
'2024-04-03'],
[['2024-04-02', '2024-04-02'],
['2024-04-04', '2024-04-02'],
['2024-04-05', '2024-04-02'],
['2024-04-03', '2024-04-03']]),
('orphan after series end',
['2024-05-01', 1, 3, [['2024-05-10', '2024-05-02']], '2024-05-01', '2024-05-10'],
[['2024-05-01', '2024-05-01'], ['2024-05-02', '2024-05-02'], ['2024-05-03', '2024-05-03']]),
('move then cancel',
['2024-06-01', 1, 3, [['2024-06-03', '2024-06-01'], ['2024-06-03', None]], '2024-06-01', '2024-06-05'],
[['2024-06-01', '2024-06-01'], ['2024-06-02', '2024-06-02']]),
('no overrides',
['2024-06-01', 3, 3, [], '2024-06-02', '2024-06-07'],
[['2024-06-04', '2024-06-04'], ['2024-06-07', '2024-06-07']]),
('regression: moved into window',
['2024-01-01', 1, 10, [['2024-01-02', '2024-01-06']], '2024-01-05', '2024-01-07'],
[['2024-01-05', '2024-01-05'],
['2024-01-02', '2024-01-06'],
['2024-01-06', '2024-01-06'],
['2024-01-07', '2024-01-07']]),
('moved out of window',
['2024-01-01', 1, 10, [['2024-01-06', '2024-01-20']], '2024-01-05', '2024-01-07'],
[['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07']]),
('cancelled instance',
['2024-01-01', 2, 5, [['2024-01-03', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'],
['2024-01-05', '2024-01-05'],
['2024-01-07', '2024-01-07'],
['2024-01-09', '2024-01-09']])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: moved into window | [['2024-01-05', '2024-01-05'], ['2024-01-02', '2024-01-06'], ['2024-01-06', '2024-01-06'], ['2024-01-07', '2024-01-07']] | [['2024-01-05', '2024-01-05'], ['2024-01-02', '2024-01-06'], ['2024-01-06', '2024-01-06'], ['2024-01-07', '2024-01-07']] | Passed |
| moved out of window | [['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07']] | [['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07']] | Passed |
| cancelled instance | [['2024-01-01', '2024-01-01'], ['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07'], ['2024-01-09', '2024-01-09']] | [['2024-01-01', '2024-01-01'], ['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07'], ['2024-01-09', '2024-01-09']] | Passed |
| orphan move | [['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07'], ['2024-01-09', '2024-01-09']] | [['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07'], ['2024-01-09', '2024-01-09']] | Passed |
| orphan cancel | [['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05']] | [['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05']] | Passed |
| last override wins | [['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-04', '2024-02-04'], ['2024-02-02', '2024-02-10']] | [['2024-02-01', '2024-02-01'], ['2024-02-02', '2024-02-03'], ['2024-02-03', '2024-02-03'], ['2024-02-04', '2024-02-04']] | Failed |
| cancel then move | [['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']] | [['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']] | Passed |
SHA-256 / e3c699338a566021f3336751ef67d14699f4688032ab1e85495e0ea41c7d0e3a
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, interval, count, overrides, window_start, window_end):
start = dt.date.fromisoformat(dtstart)
ws = dt.date.fromisoformat(window_start)
we = dt.date.fromisoformat(window_end)
originals = [start + dt.timedelta(days=k * interval) for k in range(count)]
origset = set(originals)
actual = {o: o for o in originals}
for orig, new in reversed(overrides):
o = dt.date.fromisoformat(orig)
if o not in origset:
continue
actual[o] = None if new is None else dt.date.fromisoformat(new)
rows = [[o.isoformat(), a.isoformat()] for o, a in actual.items() if a is not None and ws <= a <= we]
return sorted(rows, key=lambda r: (r[1], r[0]))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: moved into window',
['2024-01-01', 1, 10, [['2024-01-02', '2024-01-06']], '2024-01-05', '2024-01-07'],
[['2024-01-05', '2024-01-05'],
['2024-01-02', '2024-01-06'],
['2024-01-06', '2024-01-06'],
['2024-01-07', '2024-01-07']]),
('moved out of window',
['2024-01-01', 1, 10, [['2024-01-06', '2024-01-20']], '2024-01-05', '2024-01-07'],
[['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07']]),
('cancelled instance',
['2024-01-01', 2, 5, [['2024-01-03', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'],
['2024-01-05', '2024-01-05'],
['2024-01-07', '2024-01-07'],
['2024-01-09', '2024-01-09']]),
('orphan move',
['2024-01-01', 2, 5, [['2024-01-02', '2024-01-04']], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'],
['2024-01-03', '2024-01-03'],
['2024-01-05', '2024-01-05'],
['2024-01-07', '2024-01-07'],
['2024-01-09', '2024-01-09']]),
('orphan cancel',
['2024-01-01', 2, 3, [['2024-01-04', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05']]),
('last override wins',
['2024-02-01',
1,
4,
[['2024-02-02', '2024-02-10'], ['2024-02-02', '2024-02-03']],
'2024-02-01',
'2024-02-10'],
[['2024-02-01', '2024-02-01'],
['2024-02-02', '2024-02-03'],
['2024-02-03', '2024-02-03'],
['2024-02-04', '2024-02-04']]),
('cancel then move',
['2024-02-01', 1, 3, [['2024-02-02', None], ['2024-02-02', '2024-02-05']], '2024-02-01', '2024-02-05'],
[['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']])],
[('cancelled instance',
['2024-01-01', 2, 5, [['2024-01-03', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'],
['2024-01-05', '2024-01-05'],
['2024-01-07', '2024-01-07'],
['2024-01-09', '2024-01-09']]),
('orphan move',
['2024-01-01', 2, 5, [['2024-01-02', '2024-01-04']], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'],
['2024-01-03', '2024-01-03'],
['2024-01-05', '2024-01-05'],
['2024-01-07', '2024-01-07'],
['2024-01-09', '2024-01-09']]),
('orphan cancel',
['2024-01-01', 2, 3, [['2024-01-04', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05']]),
('last override wins',
['2024-02-01',
1,
4,
[['2024-02-02', '2024-02-10'], ['2024-02-02', '2024-02-03']],
'2024-02-01',
'2024-02-10'],
[['2024-02-01', '2024-02-01'],
['2024-02-02', '2024-02-03'],
['2024-02-03', '2024-02-03'],
['2024-02-04', '2024-02-04']]),
('cancel then move',
['2024-02-01', 1, 3, [['2024-02-02', None], ['2024-02-02', '2024-02-05']], '2024-02-01', '2024-02-05'],
[['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']]),
('restated original date',
['2024-03-01', 7, 3, [['2024-03-08', '2024-03-08']], '2024-03-01', '2024-03-31'],
[['2024-03-01', '2024-03-01'], ['2024-03-08', '2024-03-08'], ['2024-03-15', '2024-03-15']]),
('two moved onto same day',
['2024-04-01',
1,
5,
[['2024-04-04', '2024-04-02'], ['2024-04-05', '2024-04-02']],
'2024-04-02',
'2024-04-03'],
[['2024-04-02', '2024-04-02'],
['2024-04-04', '2024-04-02'],
['2024-04-05', '2024-04-02'],
['2024-04-03', '2024-04-03']])],
[('orphan cancel',
['2024-01-01', 2, 3, [['2024-01-04', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05']]),
('last override wins',
['2024-02-01',
1,
4,
[['2024-02-02', '2024-02-10'], ['2024-02-02', '2024-02-03']],
'2024-02-01',
'2024-02-10'],
[['2024-02-01', '2024-02-01'],
['2024-02-02', '2024-02-03'],
['2024-02-03', '2024-02-03'],
['2024-02-04', '2024-02-04']]),
('cancel then move',
['2024-02-01', 1, 3, [['2024-02-02', None], ['2024-02-02', '2024-02-05']], '2024-02-01', '2024-02-05'],
[['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']]),
('restated original date',
['2024-03-01', 7, 3, [['2024-03-08', '2024-03-08']], '2024-03-01', '2024-03-31'],
[['2024-03-01', '2024-03-01'], ['2024-03-08', '2024-03-08'], ['2024-03-15', '2024-03-15']]),
('two moved onto same day',
['2024-04-01',
1,
5,
[['2024-04-04', '2024-04-02'], ['2024-04-05', '2024-04-02']],
'2024-04-02',
'2024-04-03'],
[['2024-04-02', '2024-04-02'],
['2024-04-04', '2024-04-02'],
['2024-04-05', '2024-04-02'],
['2024-04-03', '2024-04-03']]),
('orphan after series end',
['2024-05-01', 1, 3, [['2024-05-10', '2024-05-02']], '2024-05-01', '2024-05-10'],
[['2024-05-01', '2024-05-01'], ['2024-05-02', '2024-05-02'], ['2024-05-03', '2024-05-03']]),
('move then cancel',
['2024-06-01', 1, 3, [['2024-06-03', '2024-06-01'], ['2024-06-03', None]], '2024-06-01', '2024-06-05'],
[['2024-06-01', '2024-06-01'], ['2024-06-02', '2024-06-02']])],
[('cancel then move',
['2024-02-01', 1, 3, [['2024-02-02', None], ['2024-02-02', '2024-02-05']], '2024-02-01', '2024-02-05'],
[['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']]),
('restated original date',
['2024-03-01', 7, 3, [['2024-03-08', '2024-03-08']], '2024-03-01', '2024-03-31'],
[['2024-03-01', '2024-03-01'], ['2024-03-08', '2024-03-08'], ['2024-03-15', '2024-03-15']]),
('two moved onto same day',
['2024-04-01',
1,
5,
[['2024-04-04', '2024-04-02'], ['2024-04-05', '2024-04-02']],
'2024-04-02',
'2024-04-03'],
[['2024-04-02', '2024-04-02'],
['2024-04-04', '2024-04-02'],
['2024-04-05', '2024-04-02'],
['2024-04-03', '2024-04-03']]),
('orphan after series end',
['2024-05-01', 1, 3, [['2024-05-10', '2024-05-02']], '2024-05-01', '2024-05-10'],
[['2024-05-01', '2024-05-01'], ['2024-05-02', '2024-05-02'], ['2024-05-03', '2024-05-03']]),
('move then cancel',
['2024-06-01', 1, 3, [['2024-06-03', '2024-06-01'], ['2024-06-03', None]], '2024-06-01', '2024-06-05'],
[['2024-06-01', '2024-06-01'], ['2024-06-02', '2024-06-02']]),
('no overrides',
['2024-06-01', 3, 3, [], '2024-06-02', '2024-06-07'],
[['2024-06-04', '2024-06-04'], ['2024-06-07', '2024-06-07']]),
('regression: moved into window',
['2024-01-01', 1, 10, [['2024-01-02', '2024-01-06']], '2024-01-05', '2024-01-07'],
[['2024-01-05', '2024-01-05'],
['2024-01-02', '2024-01-06'],
['2024-01-06', '2024-01-06'],
['2024-01-07', '2024-01-07']])],
[('two moved onto same day',
['2024-04-01',
1,
5,
[['2024-04-04', '2024-04-02'], ['2024-04-05', '2024-04-02']],
'2024-04-02',
'2024-04-03'],
[['2024-04-02', '2024-04-02'],
['2024-04-04', '2024-04-02'],
['2024-04-05', '2024-04-02'],
['2024-04-03', '2024-04-03']]),
('orphan after series end',
['2024-05-01', 1, 3, [['2024-05-10', '2024-05-02']], '2024-05-01', '2024-05-10'],
[['2024-05-01', '2024-05-01'], ['2024-05-02', '2024-05-02'], ['2024-05-03', '2024-05-03']]),
('move then cancel',
['2024-06-01', 1, 3, [['2024-06-03', '2024-06-01'], ['2024-06-03', None]], '2024-06-01', '2024-06-05'],
[['2024-06-01', '2024-06-01'], ['2024-06-02', '2024-06-02']]),
('no overrides',
['2024-06-01', 3, 3, [], '2024-06-02', '2024-06-07'],
[['2024-06-04', '2024-06-04'], ['2024-06-07', '2024-06-07']]),
('regression: moved into window',
['2024-01-01', 1, 10, [['2024-01-02', '2024-01-06']], '2024-01-05', '2024-01-07'],
[['2024-01-05', '2024-01-05'],
['2024-01-02', '2024-01-06'],
['2024-01-06', '2024-01-06'],
['2024-01-07', '2024-01-07']]),
('moved out of window',
['2024-01-01', 1, 10, [['2024-01-06', '2024-01-20']], '2024-01-05', '2024-01-07'],
[['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07']]),
('cancelled instance',
['2024-01-01', 2, 5, [['2024-01-03', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'],
['2024-01-05', '2024-01-05'],
['2024-01-07', '2024-01-07'],
['2024-01-09', '2024-01-09']])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: moved into window | [['2024-01-05', '2024-01-05'], ['2024-01-02', '2024-01-06'], ['2024-01-06', '2024-01-06'], ['2024-01-07', '2024-01-07']] | [['2024-01-05', '2024-01-05'], ['2024-01-02', '2024-01-06'], ['2024-01-06', '2024-01-06'], ['2024-01-07', '2024-01-07']] | Passed |
| moved out of window | [['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07']] | [['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07']] | Passed |
| cancelled instance | [['2024-01-01', '2024-01-01'], ['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07'], ['2024-01-09', '2024-01-09']] | [['2024-01-01', '2024-01-01'], ['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07'], ['2024-01-09', '2024-01-09']] | Passed |
| orphan move | [['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07'], ['2024-01-09', '2024-01-09']] | [['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07'], ['2024-01-09', '2024-01-09']] | Passed |
| orphan cancel | [['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05']] | [['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05']] | Passed |
| last override wins | [['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-04', '2024-02-04'], ['2024-02-02', '2024-02-10']] | [['2024-02-01', '2024-02-01'], ['2024-02-02', '2024-02-03'], ['2024-02-03', '2024-02-03'], ['2024-02-04', '2024-02-04']] | Failed |
| cancel then move | [['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03']] | [['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']] | Failed |
SHA-256 / 3e6e43084b4b821701435f71cc6e71c689c155593019444f02aa32b8978d92d7
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, interval, count, overrides, window_start, window_end):
start = dt.date.fromisoformat(dtstart)
ws = dt.date.fromisoformat(window_start)
we = dt.date.fromisoformat(window_end)
originals = [start + dt.timedelta(days=k * interval) for k in range(count)]
origset = set(originals)
actual = {o: o for o in originals}
for orig, new in overrides:
o = dt.date.fromisoformat(orig)
if o not in origset:
continue
actual[o] = None if new is None else dt.date.fromisoformat(new)
rows = [[o.isoformat(), a.isoformat()] for o, a in actual.items() if a is not None and ws <= a <= we]
return sorted(rows, key=lambda r: (r[1], r[0]))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: moved into window',
['2024-01-01', 1, 10, [['2024-01-02', '2024-01-06']], '2024-01-05', '2024-01-07'],
[['2024-01-05', '2024-01-05'],
['2024-01-02', '2024-01-06'],
['2024-01-06', '2024-01-06'],
['2024-01-07', '2024-01-07']]),
('moved out of window',
['2024-01-01', 1, 10, [['2024-01-06', '2024-01-20']], '2024-01-05', '2024-01-07'],
[['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07']]),
('cancelled instance',
['2024-01-01', 2, 5, [['2024-01-03', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'],
['2024-01-05', '2024-01-05'],
['2024-01-07', '2024-01-07'],
['2024-01-09', '2024-01-09']]),
('orphan move',
['2024-01-01', 2, 5, [['2024-01-02', '2024-01-04']], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'],
['2024-01-03', '2024-01-03'],
['2024-01-05', '2024-01-05'],
['2024-01-07', '2024-01-07'],
['2024-01-09', '2024-01-09']]),
('orphan cancel',
['2024-01-01', 2, 3, [['2024-01-04', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05']]),
('last override wins',
['2024-02-01',
1,
4,
[['2024-02-02', '2024-02-10'], ['2024-02-02', '2024-02-03']],
'2024-02-01',
'2024-02-10'],
[['2024-02-01', '2024-02-01'],
['2024-02-02', '2024-02-03'],
['2024-02-03', '2024-02-03'],
['2024-02-04', '2024-02-04']]),
('cancel then move',
['2024-02-01', 1, 3, [['2024-02-02', None], ['2024-02-02', '2024-02-05']], '2024-02-01', '2024-02-05'],
[['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']])],
[('cancelled instance',
['2024-01-01', 2, 5, [['2024-01-03', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'],
['2024-01-05', '2024-01-05'],
['2024-01-07', '2024-01-07'],
['2024-01-09', '2024-01-09']]),
('orphan move',
['2024-01-01', 2, 5, [['2024-01-02', '2024-01-04']], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'],
['2024-01-03', '2024-01-03'],
['2024-01-05', '2024-01-05'],
['2024-01-07', '2024-01-07'],
['2024-01-09', '2024-01-09']]),
('orphan cancel',
['2024-01-01', 2, 3, [['2024-01-04', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05']]),
('last override wins',
['2024-02-01',
1,
4,
[['2024-02-02', '2024-02-10'], ['2024-02-02', '2024-02-03']],
'2024-02-01',
'2024-02-10'],
[['2024-02-01', '2024-02-01'],
['2024-02-02', '2024-02-03'],
['2024-02-03', '2024-02-03'],
['2024-02-04', '2024-02-04']]),
('cancel then move',
['2024-02-01', 1, 3, [['2024-02-02', None], ['2024-02-02', '2024-02-05']], '2024-02-01', '2024-02-05'],
[['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']]),
('restated original date',
['2024-03-01', 7, 3, [['2024-03-08', '2024-03-08']], '2024-03-01', '2024-03-31'],
[['2024-03-01', '2024-03-01'], ['2024-03-08', '2024-03-08'], ['2024-03-15', '2024-03-15']]),
('two moved onto same day',
['2024-04-01',
1,
5,
[['2024-04-04', '2024-04-02'], ['2024-04-05', '2024-04-02']],
'2024-04-02',
'2024-04-03'],
[['2024-04-02', '2024-04-02'],
['2024-04-04', '2024-04-02'],
['2024-04-05', '2024-04-02'],
['2024-04-03', '2024-04-03']])],
[('orphan cancel',
['2024-01-01', 2, 3, [['2024-01-04', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05']]),
('last override wins',
['2024-02-01',
1,
4,
[['2024-02-02', '2024-02-10'], ['2024-02-02', '2024-02-03']],
'2024-02-01',
'2024-02-10'],
[['2024-02-01', '2024-02-01'],
['2024-02-02', '2024-02-03'],
['2024-02-03', '2024-02-03'],
['2024-02-04', '2024-02-04']]),
('cancel then move',
['2024-02-01', 1, 3, [['2024-02-02', None], ['2024-02-02', '2024-02-05']], '2024-02-01', '2024-02-05'],
[['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']]),
('restated original date',
['2024-03-01', 7, 3, [['2024-03-08', '2024-03-08']], '2024-03-01', '2024-03-31'],
[['2024-03-01', '2024-03-01'], ['2024-03-08', '2024-03-08'], ['2024-03-15', '2024-03-15']]),
('two moved onto same day',
['2024-04-01',
1,
5,
[['2024-04-04', '2024-04-02'], ['2024-04-05', '2024-04-02']],
'2024-04-02',
'2024-04-03'],
[['2024-04-02', '2024-04-02'],
['2024-04-04', '2024-04-02'],
['2024-04-05', '2024-04-02'],
['2024-04-03', '2024-04-03']]),
('orphan after series end',
['2024-05-01', 1, 3, [['2024-05-10', '2024-05-02']], '2024-05-01', '2024-05-10'],
[['2024-05-01', '2024-05-01'], ['2024-05-02', '2024-05-02'], ['2024-05-03', '2024-05-03']]),
('move then cancel',
['2024-06-01', 1, 3, [['2024-06-03', '2024-06-01'], ['2024-06-03', None]], '2024-06-01', '2024-06-05'],
[['2024-06-01', '2024-06-01'], ['2024-06-02', '2024-06-02']])],
[('cancel then move',
['2024-02-01', 1, 3, [['2024-02-02', None], ['2024-02-02', '2024-02-05']], '2024-02-01', '2024-02-05'],
[['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']]),
('restated original date',
['2024-03-01', 7, 3, [['2024-03-08', '2024-03-08']], '2024-03-01', '2024-03-31'],
[['2024-03-01', '2024-03-01'], ['2024-03-08', '2024-03-08'], ['2024-03-15', '2024-03-15']]),
('two moved onto same day',
['2024-04-01',
1,
5,
[['2024-04-04', '2024-04-02'], ['2024-04-05', '2024-04-02']],
'2024-04-02',
'2024-04-03'],
[['2024-04-02', '2024-04-02'],
['2024-04-04', '2024-04-02'],
['2024-04-05', '2024-04-02'],
['2024-04-03', '2024-04-03']]),
('orphan after series end',
['2024-05-01', 1, 3, [['2024-05-10', '2024-05-02']], '2024-05-01', '2024-05-10'],
[['2024-05-01', '2024-05-01'], ['2024-05-02', '2024-05-02'], ['2024-05-03', '2024-05-03']]),
('move then cancel',
['2024-06-01', 1, 3, [['2024-06-03', '2024-06-01'], ['2024-06-03', None]], '2024-06-01', '2024-06-05'],
[['2024-06-01', '2024-06-01'], ['2024-06-02', '2024-06-02']]),
('no overrides',
['2024-06-01', 3, 3, [], '2024-06-02', '2024-06-07'],
[['2024-06-04', '2024-06-04'], ['2024-06-07', '2024-06-07']]),
('regression: moved into window',
['2024-01-01', 1, 10, [['2024-01-02', '2024-01-06']], '2024-01-05', '2024-01-07'],
[['2024-01-05', '2024-01-05'],
['2024-01-02', '2024-01-06'],
['2024-01-06', '2024-01-06'],
['2024-01-07', '2024-01-07']])],
[('two moved onto same day',
['2024-04-01',
1,
5,
[['2024-04-04', '2024-04-02'], ['2024-04-05', '2024-04-02']],
'2024-04-02',
'2024-04-03'],
[['2024-04-02', '2024-04-02'],
['2024-04-04', '2024-04-02'],
['2024-04-05', '2024-04-02'],
['2024-04-03', '2024-04-03']]),
('orphan after series end',
['2024-05-01', 1, 3, [['2024-05-10', '2024-05-02']], '2024-05-01', '2024-05-10'],
[['2024-05-01', '2024-05-01'], ['2024-05-02', '2024-05-02'], ['2024-05-03', '2024-05-03']]),
('move then cancel',
['2024-06-01', 1, 3, [['2024-06-03', '2024-06-01'], ['2024-06-03', None]], '2024-06-01', '2024-06-05'],
[['2024-06-01', '2024-06-01'], ['2024-06-02', '2024-06-02']]),
('no overrides',
['2024-06-01', 3, 3, [], '2024-06-02', '2024-06-07'],
[['2024-06-04', '2024-06-04'], ['2024-06-07', '2024-06-07']]),
('regression: moved into window',
['2024-01-01', 1, 10, [['2024-01-02', '2024-01-06']], '2024-01-05', '2024-01-07'],
[['2024-01-05', '2024-01-05'],
['2024-01-02', '2024-01-06'],
['2024-01-06', '2024-01-06'],
['2024-01-07', '2024-01-07']]),
('moved out of window',
['2024-01-01', 1, 10, [['2024-01-06', '2024-01-20']], '2024-01-05', '2024-01-07'],
[['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07']]),
('cancelled instance',
['2024-01-01', 2, 5, [['2024-01-03', None]], '2024-01-01', '2024-01-09'],
[['2024-01-01', '2024-01-01'],
['2024-01-05', '2024-01-05'],
['2024-01-07', '2024-01-07'],
['2024-01-09', '2024-01-09']])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: moved into window | [['2024-01-05', '2024-01-05'], ['2024-01-02', '2024-01-06'], ['2024-01-06', '2024-01-06'], ['2024-01-07', '2024-01-07']] | [['2024-01-05', '2024-01-05'], ['2024-01-02', '2024-01-06'], ['2024-01-06', '2024-01-06'], ['2024-01-07', '2024-01-07']] | Passed |
| moved out of window | [['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07']] | [['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07']] | Passed |
| cancelled instance | [['2024-01-01', '2024-01-01'], ['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07'], ['2024-01-09', '2024-01-09']] | [['2024-01-01', '2024-01-01'], ['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07'], ['2024-01-09', '2024-01-09']] | Passed |
| orphan move | [['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07'], ['2024-01-09', '2024-01-09']] | [['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05'], ['2024-01-07', '2024-01-07'], ['2024-01-09', '2024-01-09']] | Passed |
| orphan cancel | [['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05']] | [['2024-01-01', '2024-01-01'], ['2024-01-03', '2024-01-03'], ['2024-01-05', '2024-01-05']] | Passed |
| last override wins | [['2024-02-01', '2024-02-01'], ['2024-02-02', '2024-02-03'], ['2024-02-03', '2024-02-03'], ['2024-02-04', '2024-02-04']] | [['2024-02-01', '2024-02-01'], ['2024-02-02', '2024-02-03'], ['2024-02-03', '2024-02-03'], ['2024-02-04', '2024-02-04']] | Passed |
| cancel then move | [['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']] | [['2024-02-01', '2024-02-01'], ['2024-02-03', '2024-02-03'], ['2024-02-02', '2024-02-05']] | Passed |
SHA-256 / 423101d484a86734c384865243a3af20492ccb7cfb288497688157f467eb9038
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:21.287847+00:00.
Case digest / 9ad91c4eb2b8077d0c6a0cf0e84281b2affcabe98d97c5d5d981d0026f8de97f