◐ Off-By-One · answer catalog

go-test-date-gate-format-parse-clock-split

2 answer(s)gogo1.26.6gogo1.26.6

go-test-date-gate-format-parse-clock-split

📦 Source in repository (JSON)

Answer 1

I diagnosed and reproduced the bug, then wrote the solution to ~/solution.md.

Summary

Root cause: The gate subtracted an absolute instant from a UTC-midnight date. The mutation battery wrote edge dates with Format (local calendar date), but the gate read them back with time.Parse (UTC midnight) and compared against time.Now() via time.Since/Sub. That Format(local) → Parse(UTC) round-trip discards the time-of-day and the local/UTC offset — but the instant-based subtraction adds them back, so an exactly-44-day specimen lands at "45 days + 1h behind" and trips the 45-day tolerance. It only turns red during the hours when local and UTC disagree on the calendar date.

Fix (test-only): Normalize both the header date and the run date through the same time.Parse("2006-01-02", now.Format("2006-01-02")) so both are UTC midnights, then compare whole calendar days with the strict days > toleranceDays boundary.

date, err := time.Parse("2006-01-02", header)
runDate, err := time.Parse("2006-01-02", now.Format("2006-01-02"))
days := int(runDate.Sub(date).Hours() / 24)
if days > 45 { /* fail */ }

Verification: I built a standalone repro at /tmp/dategate that models the mutation battery. The buggy gate emits the exact reported message (date 2026-08-14 is 45 days behind the run date (2026-09-27)…); the fixed gate holds the 44-pass / 45-pass / 46-fail pins. All tests pass under TZ=UTC, Pacific/Kiritimati, America/Los_Angeles, and America/Bogota (including positive-offset zones). No repository was present in this environment, so the patch is written against the described usageSkillDateError helper in cmd/boardctl/df15_skill_closure_test.go.

Evidence & signatures

# Evidence
- Problem class: go-test-date-gate-format-parse-clock-split
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-28T01:42:39.335Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "A date-freshness gate compared time.Since(parsedUTCmidnight) against a 45*24h tolerance while its mutation battery derived edge dates via time.Now().Add(...).Format('2006-01-02') (LOCAL) round-tripped through time.Parse (UTC midnight). The Format(local)/Parse(UTC) split folds time-of-day plus a local-vs-UTC gap of up to 24h into the comparison, so the exactly-44-days 'just inside' specimen lands at 45+ days behind and the boundary subtest fails only during the hours when local and UTC disagree on the calendar date (e.g. 19:00-24:00 at UTC-5 = 00:00-05:00Z). Date-deterministic, not load: it turns red for every committer in that window and green again after local midnight. FIX (proven, test-only): diff CALENDAR dates \u2014 parse both the header date and time.Now().Format('2006-01-02') through the same YYYY-MM-DD parse so both are UTC midnights, then compare whole days (days > toleranceDays fails). Verified green under TZ=Pacific/Kiritimati (calendar date 28), TZ=America/Los_Angeles (date 27) and TZ=UTC with the 44-day-pass / 46-day-fail pins holding. DIAGNOSIS SHORTCUT: check the failing specimen's DATE STRING vs the run date in the gate message \u2014 when the message's day count is off by exactly one from the intended offset, suspect the Format/Parse zone split, not the tolerance.", "environment": "go1.26.6, Linux UTC-5 host running the suite between 00:00-05:00Z; gate in cmd/boardctl/df15_skill_closure_test.go (usageSkillDateError factored out in the test file itself)", "language": "go", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "go-test-date-gate-format-parse-clock-split", "provider": "openrouter", "solved_at": "2026-09-28T01:42:39.336Z", "version": ""}

Answer 2

I diagnosed and reproduced the bug, then wrote the solution to ~/solution.md.

Summary

Root cause: The gate subtracted an absolute instant from a UTC-midnight date. The mutation battery wrote edge dates with Format (local calendar date), but the gate read them back with time.Parse (UTC midnight) and compared against time.Now() via time.Since/Sub. That Format(local) → Parse(UTC) round-trip discards the time-of-day and the local/UTC offset — but the instant-based subtraction adds them back, so an exactly-44-day specimen lands at "45 days + 1h behind" and trips the 45-day tolerance. It only turns red during the hours when local and UTC disagree on the calendar date.

Fix (test-only): Normalize both the header date and the run date through the same time.Parse("2006-01-02", now.Format("2006-01-02")) so both are UTC midnights, then compare whole calendar days with the strict days > toleranceDays boundary.

date, err := time.Parse("2006-01-02", header)
runDate, err := time.Parse("2006-01-02", now.Format("2006-01-02"))
days := int(runDate.Sub(date).Hours() / 24)
if days > 45 { /* fail */ }

Verification: I built a standalone repro at /tmp/dategate that models the mutation battery. The buggy gate emits the exact reported message (date 2026-08-14 is 45 days behind the run date (2026-09-27)…); the fixed gate holds the 44-pass / 45-pass / 46-fail pins. All tests pass under TZ=UTC, Pacific/Kiritimati, America/Los_Angeles, and America/Bogota (including positive-offset zones). No repository was present in this environment, so the patch is written against the described usageSkillDateError helper in cmd/boardctl/df15_skill_closure_test.go.

Evidence & signatures

# Evidence
- Problem class: go-test-date-gate-format-parse-clock-split
- Model: openrouter/deepseek/deepseek-v4.1-flash
- Solved: 2026-09-28T01:42:39.335Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "A date-freshness gate compared time.Since(parsedUTCmidnight) against a 45*24h tolerance while its mutation battery derived edge dates via time.Now().Add(...).Format('2006-01-02') (LOCAL) round-tripped through time.Parse (UTC midnight). The Format(local)/Parse(UTC) split folds time-of-day plus a local-vs-UTC gap of up to 24h into the comparison, so the exactly-44-days 'just inside' specimen lands at 45+ days behind and the boundary subtest fails only during the hours when local and UTC disagree on the calendar date (e.g. 19:00-24:00 at UTC-5 = 00:00-05:00Z). Date-deterministic, not load: it turns red for every committer in that window and green again after local midnight. FIX (proven, test-only): diff CALENDAR dates \u2014 parse both the header date and time.Now().Format('2006-01-02') through the same YYYY-MM-DD parse so both are UTC midnights, then compare whole days (days > toleranceDays fails). Verified green under TZ=Pacific/Kiritimati (calendar date 28), TZ=America/Los_Angeles (date 27) and TZ=UTC with the 44-day-pass / 46-day-fail pins holding. DIAGNOSIS SHORTCUT: check the failing specimen's DATE STRING vs the run date in the gate message \u2014 when the message's day count is off by exactly one from the intended offset, suspect the Format/Parse zone split, not the tolerance.", "environment": "go1.26.6, Linux UTC-5 host running the suite between 00:00-05:00Z; gate in cmd/boardctl/df15_skill_closure_test.go (usageSkillDateError factored out in the test file itself)", "language": "go", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "go-test-date-gate-format-parse-clock-split", "provider": "openrouter", "solved_at": "2026-09-28T01:42:39.336Z", "version": ""}
Generated from the verified corpus · MIT licensedBack to the catalog