FA-77736 / Legal deadline computation / Open access
Stacking stipulated extensions under a cumulative cap: re roll · case 01
An extension ending on a Saturday leaves the deadline on the Saturday.
ROOT CAUSE
The extended deadline is not moved off a closed day.
VERIFIED REPAIR
At the re roll decision use `roll(nxt)`, leaving the other decision sites of the model unchanged.
Unsuccessful approach: The partial repair `nxt if nxt.weekday() < 5 else roll(nxt)` rolls weekends but leaves a deadline on a weekday holiday.
Case contract
Stipulated: the original deadline (rolled forward to an open day) may be extended by stipulations [signed, days] processed in order, without court order, up to 30 days in total across all stipulations. A stipulation is valid only if signed on or before the then-current deadline; it grants min(days, remaining cap), added to the current deadline, and the result is rolled forward to an open day (not weekend or listed holiday). Return [final deadline, total days granted].
Why this case matters
Docketing systems compute filing and response deadlines from trigger events; a wrong date can forfeit a right.
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(original, stipulations, holidays):
hol = {dt.date.fromisoformat(x) for x in holidays}
def roll(d):
while d.weekday() >= 5 or d in hol:
d += dt.timedelta(days=1)
return d
base = roll(dt.date.fromisoformat(original))
cur = base
used = 0
for signed, days in stipulations:
s = dt.date.fromisoformat(signed)
if s > cur:
continue
grant = min(days, 30 - used)
if grant <= 0:
continue
used += grant
nxt = cur + dt.timedelta(days=grant)
cur = nxt
return [cur.isoformat(), used]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: second stipulation after original',
['2024-03-01',
[['2024-02-28', 10], ['2024-03-08', 10]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-03-21', 20]),
('cap exceeded',
['2024-04-01',
[['2024-03-30', 14], ['2024-04-10', 14], ['2024-04-20', 14]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-05-01', 30]),
('signed on deadline day',
['2024-04-01',
[['2024-04-01', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 7]),
('late stipulation',
['2024-04-01',
[['2024-04-02', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-01', 0]),
('extension to saturday',
['2024-04-01',
[['2024-03-25', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 5]),
('extension to holiday',
['2024-06-12',
[['2024-06-10', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-20', 7]),
('original on weekend',
['2024-06-01',
[['2024-06-03', 3]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-06', 3])],
[('signed on deadline day',
['2024-04-01',
[['2024-04-01', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 7]),
('late stipulation',
['2024-04-01',
[['2024-04-02', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-01', 0]),
('extension to saturday',
['2024-04-01',
[['2024-03-25', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 5]),
('extension to holiday',
['2024-06-12',
[['2024-06-10', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-20', 7]),
('original on weekend',
['2024-06-01',
[['2024-06-03', 3]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-06', 3]),
('exact cap',
['2024-01-08',
[['2024-01-05', 20], ['2024-01-20', 10], ['2024-02-01', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-02-08', 30]),
('single thirty',
['2024-08-01',
[['2024-07-01', 30]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-03', 30])],
[('extension to saturday',
['2024-04-01',
[['2024-03-25', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 5]),
('extension to holiday',
['2024-06-12',
[['2024-06-10', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-20', 7]),
('original on weekend',
['2024-06-01',
[['2024-06-03', 3]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-06', 3]),
('exact cap',
['2024-01-08',
[['2024-01-05', 20], ['2024-01-20', 10], ['2024-02-01', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-02-08', 30]),
('single thirty',
['2024-08-01',
[['2024-07-01', 30]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-03', 30]),
('three stacked short',
['2024-09-03',
[['2024-09-01', 3], ['2024-09-05', 4], ['2024-09-09', 2]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-12', 9]),
('regression: second stipulation after original',
['2024-03-01',
[['2024-02-28', 10], ['2024-03-08', 10]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-03-21', 20])],
[('original on weekend',
['2024-06-01',
[['2024-06-03', 3]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-06', 3]),
('exact cap',
['2024-01-08',
[['2024-01-05', 20], ['2024-01-20', 10], ['2024-02-01', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-02-08', 30]),
('single thirty',
['2024-08-01',
[['2024-07-01', 30]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-03', 30]),
('three stacked short',
['2024-09-03',
[['2024-09-01', 3], ['2024-09-05', 4], ['2024-09-09', 2]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-12', 9]),
('regression: second stipulation after original',
['2024-03-01',
[['2024-02-28', 10], ['2024-03-08', 10]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-03-21', 20]),
('cap exceeded',
['2024-04-01',
[['2024-03-30', 14], ['2024-04-10', 14], ['2024-04-20', 14]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-05-01', 30]),
('signed on deadline day',
['2024-04-01',
[['2024-04-01', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 7]),
('extension to holiday',
['2024-06-12',
[['2024-06-10', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-20', 7])],
[('single thirty',
['2024-08-01',
[['2024-07-01', 30]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-03', 30]),
('three stacked short',
['2024-09-03',
[['2024-09-01', 3], ['2024-09-05', 4], ['2024-09-09', 2]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-12', 9]),
('regression: second stipulation after original',
['2024-03-01',
[['2024-02-28', 10], ['2024-03-08', 10]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-03-21', 20]),
('cap exceeded',
['2024-04-01',
[['2024-03-30', 14], ['2024-04-10', 14], ['2024-04-20', 14]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-05-01', 30]),
('signed on deadline day',
['2024-04-01',
[['2024-04-01', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 7]),
('late stipulation',
['2024-04-01',
[['2024-04-02', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-01', 0]),
('extension to saturday',
['2024-04-01',
[['2024-03-25', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 5]),
('extension to holiday',
['2024-06-12',
[['2024-06-10', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-20', 7])]]
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: second stipulation after original | ['2024-03-21', 20] | ['2024-03-21', 20] | Passed |
| cap exceeded | ['2024-05-01', 30] | ['2024-05-01', 30] | Passed |
| signed on deadline day | ['2024-04-08', 7] | ['2024-04-08', 7] | Passed |
| late stipulation | ['2024-04-01', 0] | ['2024-04-01', 0] | Passed |
| extension to saturday | ['2024-04-06', 5] | ['2024-04-08', 5] | Failed |
| extension to holiday | ['2024-06-19', 7] | ['2024-06-20', 7] | Failed |
| original on weekend | ['2024-06-06', 3] | ['2024-06-06', 3] | Passed |
SHA-256 / 8f9110ced4d47cd6694713056dc5078cfe166edea767b4d69bb39061dcdcc215
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(original, stipulations, holidays):
hol = {dt.date.fromisoformat(x) for x in holidays}
def roll(d):
while d.weekday() >= 5 or d in hol:
d += dt.timedelta(days=1)
return d
base = roll(dt.date.fromisoformat(original))
cur = base
used = 0
for signed, days in stipulations:
s = dt.date.fromisoformat(signed)
if s > cur:
continue
grant = min(days, 30 - used)
if grant <= 0:
continue
used += grant
nxt = cur + dt.timedelta(days=grant)
cur = nxt if nxt.weekday() < 5 else roll(nxt)
return [cur.isoformat(), used]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: second stipulation after original',
['2024-03-01',
[['2024-02-28', 10], ['2024-03-08', 10]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-03-21', 20]),
('cap exceeded',
['2024-04-01',
[['2024-03-30', 14], ['2024-04-10', 14], ['2024-04-20', 14]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-05-01', 30]),
('signed on deadline day',
['2024-04-01',
[['2024-04-01', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 7]),
('late stipulation',
['2024-04-01',
[['2024-04-02', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-01', 0]),
('extension to saturday',
['2024-04-01',
[['2024-03-25', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 5]),
('extension to holiday',
['2024-06-12',
[['2024-06-10', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-20', 7]),
('original on weekend',
['2024-06-01',
[['2024-06-03', 3]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-06', 3])],
[('signed on deadline day',
['2024-04-01',
[['2024-04-01', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 7]),
('late stipulation',
['2024-04-01',
[['2024-04-02', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-01', 0]),
('extension to saturday',
['2024-04-01',
[['2024-03-25', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 5]),
('extension to holiday',
['2024-06-12',
[['2024-06-10', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-20', 7]),
('original on weekend',
['2024-06-01',
[['2024-06-03', 3]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-06', 3]),
('exact cap',
['2024-01-08',
[['2024-01-05', 20], ['2024-01-20', 10], ['2024-02-01', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-02-08', 30]),
('single thirty',
['2024-08-01',
[['2024-07-01', 30]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-03', 30])],
[('extension to saturday',
['2024-04-01',
[['2024-03-25', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 5]),
('extension to holiday',
['2024-06-12',
[['2024-06-10', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-20', 7]),
('original on weekend',
['2024-06-01',
[['2024-06-03', 3]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-06', 3]),
('exact cap',
['2024-01-08',
[['2024-01-05', 20], ['2024-01-20', 10], ['2024-02-01', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-02-08', 30]),
('single thirty',
['2024-08-01',
[['2024-07-01', 30]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-03', 30]),
('three stacked short',
['2024-09-03',
[['2024-09-01', 3], ['2024-09-05', 4], ['2024-09-09', 2]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-12', 9]),
('regression: second stipulation after original',
['2024-03-01',
[['2024-02-28', 10], ['2024-03-08', 10]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-03-21', 20])],
[('original on weekend',
['2024-06-01',
[['2024-06-03', 3]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-06', 3]),
('exact cap',
['2024-01-08',
[['2024-01-05', 20], ['2024-01-20', 10], ['2024-02-01', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-02-08', 30]),
('single thirty',
['2024-08-01',
[['2024-07-01', 30]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-03', 30]),
('three stacked short',
['2024-09-03',
[['2024-09-01', 3], ['2024-09-05', 4], ['2024-09-09', 2]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-12', 9]),
('regression: second stipulation after original',
['2024-03-01',
[['2024-02-28', 10], ['2024-03-08', 10]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-03-21', 20]),
('cap exceeded',
['2024-04-01',
[['2024-03-30', 14], ['2024-04-10', 14], ['2024-04-20', 14]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-05-01', 30]),
('signed on deadline day',
['2024-04-01',
[['2024-04-01', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 7]),
('extension to holiday',
['2024-06-12',
[['2024-06-10', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-20', 7])],
[('single thirty',
['2024-08-01',
[['2024-07-01', 30]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-03', 30]),
('three stacked short',
['2024-09-03',
[['2024-09-01', 3], ['2024-09-05', 4], ['2024-09-09', 2]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-12', 9]),
('regression: second stipulation after original',
['2024-03-01',
[['2024-02-28', 10], ['2024-03-08', 10]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-03-21', 20]),
('cap exceeded',
['2024-04-01',
[['2024-03-30', 14], ['2024-04-10', 14], ['2024-04-20', 14]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-05-01', 30]),
('signed on deadline day',
['2024-04-01',
[['2024-04-01', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 7]),
('late stipulation',
['2024-04-01',
[['2024-04-02', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-01', 0]),
('extension to saturday',
['2024-04-01',
[['2024-03-25', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 5]),
('extension to holiday',
['2024-06-12',
[['2024-06-10', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-20', 7])]]
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: second stipulation after original | ['2024-03-21', 20] | ['2024-03-21', 20] | Passed |
| cap exceeded | ['2024-05-01', 30] | ['2024-05-01', 30] | Passed |
| signed on deadline day | ['2024-04-08', 7] | ['2024-04-08', 7] | Passed |
| late stipulation | ['2024-04-01', 0] | ['2024-04-01', 0] | Passed |
| extension to saturday | ['2024-04-08', 5] | ['2024-04-08', 5] | Passed |
| extension to holiday | ['2024-06-19', 7] | ['2024-06-20', 7] | Failed |
| original on weekend | ['2024-06-06', 3] | ['2024-06-06', 3] | Passed |
SHA-256 / f94f46659833a03ae6e53f5aedc1f7f600474bcd6ed83e62277ccdc6e3968c98
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(original, stipulations, holidays):
hol = {dt.date.fromisoformat(x) for x in holidays}
def roll(d):
while d.weekday() >= 5 or d in hol:
d += dt.timedelta(days=1)
return d
base = roll(dt.date.fromisoformat(original))
cur = base
used = 0
for signed, days in stipulations:
s = dt.date.fromisoformat(signed)
if s > cur:
continue
grant = min(days, 30 - used)
if grant <= 0:
continue
used += grant
nxt = cur + dt.timedelta(days=grant)
cur = roll(nxt)
return [cur.isoformat(), used]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: second stipulation after original',
['2024-03-01',
[['2024-02-28', 10], ['2024-03-08', 10]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-03-21', 20]),
('cap exceeded',
['2024-04-01',
[['2024-03-30', 14], ['2024-04-10', 14], ['2024-04-20', 14]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-05-01', 30]),
('signed on deadline day',
['2024-04-01',
[['2024-04-01', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 7]),
('late stipulation',
['2024-04-01',
[['2024-04-02', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-01', 0]),
('extension to saturday',
['2024-04-01',
[['2024-03-25', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 5]),
('extension to holiday',
['2024-06-12',
[['2024-06-10', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-20', 7]),
('original on weekend',
['2024-06-01',
[['2024-06-03', 3]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-06', 3])],
[('signed on deadline day',
['2024-04-01',
[['2024-04-01', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 7]),
('late stipulation',
['2024-04-01',
[['2024-04-02', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-01', 0]),
('extension to saturday',
['2024-04-01',
[['2024-03-25', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 5]),
('extension to holiday',
['2024-06-12',
[['2024-06-10', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-20', 7]),
('original on weekend',
['2024-06-01',
[['2024-06-03', 3]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-06', 3]),
('exact cap',
['2024-01-08',
[['2024-01-05', 20], ['2024-01-20', 10], ['2024-02-01', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-02-08', 30]),
('single thirty',
['2024-08-01',
[['2024-07-01', 30]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-03', 30])],
[('extension to saturday',
['2024-04-01',
[['2024-03-25', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 5]),
('extension to holiday',
['2024-06-12',
[['2024-06-10', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-20', 7]),
('original on weekend',
['2024-06-01',
[['2024-06-03', 3]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-06', 3]),
('exact cap',
['2024-01-08',
[['2024-01-05', 20], ['2024-01-20', 10], ['2024-02-01', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-02-08', 30]),
('single thirty',
['2024-08-01',
[['2024-07-01', 30]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-03', 30]),
('three stacked short',
['2024-09-03',
[['2024-09-01', 3], ['2024-09-05', 4], ['2024-09-09', 2]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-12', 9]),
('regression: second stipulation after original',
['2024-03-01',
[['2024-02-28', 10], ['2024-03-08', 10]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-03-21', 20])],
[('original on weekend',
['2024-06-01',
[['2024-06-03', 3]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-06', 3]),
('exact cap',
['2024-01-08',
[['2024-01-05', 20], ['2024-01-20', 10], ['2024-02-01', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-02-08', 30]),
('single thirty',
['2024-08-01',
[['2024-07-01', 30]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-03', 30]),
('three stacked short',
['2024-09-03',
[['2024-09-01', 3], ['2024-09-05', 4], ['2024-09-09', 2]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-12', 9]),
('regression: second stipulation after original',
['2024-03-01',
[['2024-02-28', 10], ['2024-03-08', 10]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-03-21', 20]),
('cap exceeded',
['2024-04-01',
[['2024-03-30', 14], ['2024-04-10', 14], ['2024-04-20', 14]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-05-01', 30]),
('signed on deadline day',
['2024-04-01',
[['2024-04-01', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 7]),
('extension to holiday',
['2024-06-12',
[['2024-06-10', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-20', 7])],
[('single thirty',
['2024-08-01',
[['2024-07-01', 30]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-03', 30]),
('three stacked short',
['2024-09-03',
[['2024-09-01', 3], ['2024-09-05', 4], ['2024-09-09', 2]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-09-12', 9]),
('regression: second stipulation after original',
['2024-03-01',
[['2024-02-28', 10], ['2024-03-08', 10]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-03-21', 20]),
('cap exceeded',
['2024-04-01',
[['2024-03-30', 14], ['2024-04-10', 14], ['2024-04-20', 14]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-05-01', 30]),
('signed on deadline day',
['2024-04-01',
[['2024-04-01', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 7]),
('late stipulation',
['2024-04-01',
[['2024-04-02', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-01', 0]),
('extension to saturday',
['2024-04-01',
[['2024-03-25', 5]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-04-08', 5]),
('extension to holiday',
['2024-06-12',
[['2024-06-10', 7]],
['2024-01-01',
'2024-01-15',
'2024-02-19',
'2024-05-27',
'2024-06-19',
'2024-07-04',
'2024-09-02',
'2024-10-14',
'2024-11-11',
'2024-11-28',
'2024-12-25']],
['2024-06-20', 7])]]
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: second stipulation after original | ['2024-03-21', 20] | ['2024-03-21', 20] | Passed |
| cap exceeded | ['2024-05-01', 30] | ['2024-05-01', 30] | Passed |
| signed on deadline day | ['2024-04-08', 7] | ['2024-04-08', 7] | Passed |
| late stipulation | ['2024-04-01', 0] | ['2024-04-01', 0] | Passed |
| extension to saturday | ['2024-04-08', 5] | ['2024-04-08', 5] | Passed |
| extension to holiday | ['2024-06-20', 7] | ['2024-06-20', 7] | Passed |
| original on weekend | ['2024-06-06', 3] | ['2024-06-06', 3] | Passed |
SHA-256 / 7d22373aa668b1a24931037f165f276fb93c8c98a3581a3d2d9b0212daaffd8a
Verification & scope
Stipulated toy deadline rules evaluated offline on explicit fixtures. The contract is inspired by common court-rule structures but is not legal advice and makes no claim to reproduce any jurisdiction's rules. 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:28.587978+00:00.
Case digest / 0aea6388232fc71903f3d30ebda58cd41d710f1ac37b1be0d88ae374fb806777