Implement anchor-date cycle position arithmetic (Feature 05, task 2) #58

Member

Task 2 of Feature 05.

Delivered

  • presence.cycle_week_index: ((target - anchor).days // 7) % cycle_length_weeks — anchor-date arithmetic only (D-004). Floor division walks pre-anchor dates backwards through the cycle without inverting; strict plain-date parsing on the target.
  • Tests: formula offsets across the two-week wrap, three-week wrap, pre-anchor walking, day-by-day stability across three year boundaries including 2020 (53 ISO weeks — the week-parity regression), and a source guard that the module never calls isocalendar/isoweek.

Verification

uv run pytest: 980 passed.

Closes task 06cc4782 (Feature 05).

Task 2 of Feature 05. ## Delivered - **presence.cycle_week_index**: ((target - anchor).days // 7) % cycle_length_weeks — anchor-date arithmetic only (D-004). Floor division walks pre-anchor dates backwards through the cycle without inverting; strict plain-date parsing on the target. - **Tests**: formula offsets across the two-week wrap, three-week wrap, pre-anchor walking, day-by-day stability across three year boundaries including 2020 (53 ISO weeks — the week-parity regression), and a source guard that the module never calls isocalendar/isoweek. ## Verification uv run pytest: 980 passed. Closes task 06cc4782 (Feature 05).
dev_agent added 1 commit 2026-09-15 17:51:30 -04:00
presence.cycle_week_index: ((target_date - anchor_date).days // 7) %
cycle_length_weeks — anchor-date arithmetic ONLY (D-004).  Python
floor division makes pre-anchor dates walk the cycle backwards
(day -1 is the last week), never inverting; the modulo of a negative
stays non-negative, so the index is always a valid week index.  The
target date passes through the model's strict plain-date parsing.
Tests: formula offsets, three-week pattern wrap, backwards walking,
day-by-day stability across three Dec-31 -> Jan-1 boundaries
including 2020 (verified 53 ISO weeks — the parity-inversion
regression), and a source guard that the module never reads ISO week
numbers.  Suite: 980 passed.
overseer added 1 commit 2026-09-15 17:54:28 -04:00
Review round 1 (Codex gpt-5.6-terra, LOW): the boundary walk asserted
transitions in {(same, +1)} which even a reset/inverting
implementation could satisfy on a two-week cycle. The test now
asserts a hand-verified table of expected indices for every day
around each of the three Dec-31/Jan-1 boundaries (2019/2020/2021,
anchor 2019-01-06), so a parity bug cannot pass by coincidence.
Suite: 980 passed.
Member

Independent review — Codex gpt-5.6-terra

Round 1 — CHANGES_REQUIRED (LOW): the boundary walk asserted transitions a reset/inverting implementation could also satisfy on a two-week cycle. Fixed in 77c4db7: hand-verified expected indices hardcoded for every day around all three year boundaries.
Round 2 — APPROVED (zero findings). Suite 980 passed, reviewer-verified.

## Independent review — Codex gpt-5.6-terra **Round 1 — CHANGES_REQUIRED (LOW):** the boundary walk asserted transitions a reset/inverting implementation could also satisfy on a two-week cycle. *Fixed in 77c4db7:* hand-verified expected indices hardcoded for every day around all three year boundaries. **Round 2 — APPROVED (zero findings).** Suite 980 passed, reviewer-verified.
dev_agent merged commit ee994a3938 into feature/167e3565-704d-41c7-adf6-3b88ed266f78-presence-custody-schedules 2026-09-15 17:55:22 -04:00
Sign in to join this conversation.
No Reviewers
No labels
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Maniacs_Mansion/NestQuest#58