FA-6531 / Calendar arithmetic / Open access
Monday start of week · case 01
One-based weekday is subtracted as a zero-based offset.
ROOT CAUSE
One-based weekday is subtracted as a zero-based offset.
VERIFIED REPAIR
Apply the specified mathematical contract directly, preserving all terms and boundary cases: return (date.fromisoformat(text)-timedelta(days=date.fromisoformat(text).weekday())).isoformat()
Unsuccessful approach: The week is anchored to Sunday rather than Monday.
Case contract
Valid ISO Gregorian dates in years 1 through 9999; generated dates must remain in that range. Month is 1 through 12 and zero-based weekday is Monday 0 through Sunday 6 unless the output convention says otherwise. Monday start of week. Exact operational definition: (date.fromisoformat(text)-timedelta(days=date.fromisoformat(text).weekday())).isoformat()
Why this case matters
Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Calendar conventions results depend on the stated convention.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(text):
return (date.fromisoformat(text)-timedelta(days=date.fromisoformat(text).isoweekday())).isoformat()
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check("fixture 1: ('2024-01-01',)", solve(*('2024-01-01',)), '2024-01-01')
check("fixture 2: ('2024-01-07',)", solve(*('2024-01-07',)), '2024-01-01')
check("fixture 3: ('2024-01-10',)", solve(*('2024-01-10',)), '2024-01-08')
check("fixture 4: ('2023-01-01',)", solve(*('2023-01-01',)), '2022-12-26')
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 |
|---|---|---|---|
| fixture 1: ('2024-01-01',) | 2023-12-31 | 2024-01-01 | Failed |
| fixture 2: ('2024-01-07',) | 2023-12-31 | 2024-01-01 | Failed |
| fixture 3: ('2024-01-10',) | 2024-01-07 | 2024-01-08 | Failed |
| fixture 4: ('2023-01-01',) | 2022-12-25 | 2022-12-26 | Failed |
SHA-256 / 49799bae819297980715db47c37ff2fcfb0d3bcbc4523a55258ef941dad9e2a8
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(text):
return (date.fromisoformat(text)-timedelta(days=(date.fromisoformat(text).weekday()+1)%7)).isoformat()
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check("fixture 1: ('2024-01-01',)", solve(*('2024-01-01',)), '2024-01-01')
check("fixture 2: ('2024-01-07',)", solve(*('2024-01-07',)), '2024-01-01')
check("fixture 3: ('2024-01-10',)", solve(*('2024-01-10',)), '2024-01-08')
check("fixture 4: ('2023-01-01',)", solve(*('2023-01-01',)), '2022-12-26')
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 |
|---|---|---|---|
| fixture 1: ('2024-01-01',) | 2023-12-31 | 2024-01-01 | Failed |
| fixture 2: ('2024-01-07',) | 2024-01-07 | 2024-01-01 | Failed |
| fixture 3: ('2024-01-10',) | 2024-01-07 | 2024-01-08 | Failed |
| fixture 4: ('2023-01-01',) | 2023-01-01 | 2022-12-26 | Failed |
SHA-256 / f7665317b45ac8712d478474d84488b90c2be566cd6ac8fa663a414db121fbea
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(text):
return (date.fromisoformat(text)-timedelta(days=date.fromisoformat(text).weekday())).isoformat()
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check("fixture 1: ('2024-01-01',)", solve(*('2024-01-01',)), '2024-01-01')
check("fixture 2: ('2024-01-07',)", solve(*('2024-01-07',)), '2024-01-01')
check("fixture 3: ('2024-01-10',)", solve(*('2024-01-10',)), '2024-01-08')
check("fixture 4: ('2023-01-01',)", solve(*('2023-01-01',)), '2022-12-26')
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 |
|---|---|---|---|
| fixture 1: ('2024-01-01',) | 2024-01-01 | 2024-01-01 | Passed |
| fixture 2: ('2024-01-07',) | 2024-01-01 | 2024-01-01 | Passed |
| fixture 3: ('2024-01-10',) | 2024-01-08 | 2024-01-08 | Passed |
| fixture 4: ('2023-01-01',) | 2022-12-26 | 2022-12-26 | Passed |
SHA-256 / 41ce70c42fb18ae32616a3c663294ecc2a76d2ed1a03bd9a7d44f990dea385cb
Verification & scope
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:38:02.988308+00:00.
Case digest / f9f2dabe551b800b43e3f2daaaebd0021e255930b0f2b2c5e9ac1be0aa7153dc